CopyServerDataToDataObject

Prototype

Matrix CopyServerDataToDataObject( Matrix mLibref, Matrix mDataSetName, DataObject dobj, Matrix mServerVarNames, Matrix mDobjVarNames, Matrix mDobjVarLabels, Matrix mReplaceExistingVarFlag )

Return Value

The return value is 1 on success or 0 on failure.

Parameters

Matrix mLibref
A character matrix containing the libref of the library that contains the data to be copied into the DataObject.

Matrix mDataSetName
A character matrix containing the name of the data set that contains the data to be copied into the DataObject.

DataObject dobj
The DataObject to which data will be copied.

Matrix mServerVarNames
The names in the server data set of the variables you want copied into the DataObject.

Matrix mDobjVarNames
The names to assign to the variables in the DataObject. Often you will want to set mDobjVarNames equal to mServerVarNames. Sometimes, however, you may want the variable names in the DataObject to be different from the variable names on the server.

Matrix mDobjVarLabels
The labels to assign to the variables copied into the DataObject.  If mDobjVarLabels is an empty matrix, the labels in the server data set will be used.

Matrix mReplaceExistingVarFlag
A flag that determines how to handle copying when there is an existing variable of the same name in the DataObject. If mReplaceExistingVarFlag is 0, the module will not change an existing variable. If mReplaceExistingVarFlag is 1, the module will delete an existing variable (thus closing any plots using the variable) and then add a new variable of the same name. If mReplaceExistingVarFlag is 2, the module will replace the data contained in an existing variable without first deleting the variable.

Remarks

This module copies variables from a server data set into a DataObject. If the server data set has the same number of observations as the DataObject, all observations are copied. If the server data set has the same number of observations as the DataObject has observations included in analyses, the server data is copied into those observations and observations not included in analyses are assigned missing values.

Example
x = T(1:10);
declare DataObject dobj = DataObject.Create( "Sample" );
dobj.AddVar( "ObsNum", x );
submit;
    data A;
    do i = 11 to 20;
       y = rand('chisquare',7);
       output;
    end;
    run;
endsubmit;
ok = CopyServerDataToDataObject( "work", "A", dobj, {"i" "y"},
     {"ObsNum" "RandChiSq"},
     {"Observation Number" "Random Number (Chi-Square)"}, 0);
DataTable.Create(dobj).ActivateWindow();
See Also

DataObject.CreateFromServerDataSet