1.

State the difference between using the drop = data set option in the set statement and data statement.

Answer»

In SAS, the drop= option is used to exclude variables from processing or from the OUTPUT data set. This option tells SAS which variables you wish to remove from a data set.

  • The drop= option in the set statement can be used if you do not wish to process certain variables or do not want to have them included in the new data set.
  • However, if you want to process certain variables but don't want them to be included in the new data set, then choose drop= in the data statement.

Syntax: DROP=variable(s);

In this case, variable(s) lists one or more names of variables. Variables can be listed in any format SAS supports. 

Example: Consider the following data set: 

DATA outdata; INPUT GENDER $ section score1 score2; DATALINES; F A 17 20 F B 25 17 F C 12 15 M D 21 25 ; proc print; run;

The following DROP= data set option command SAS to drop variables score1 and score2. 

data READIN; set outdata (drop = score1 score2); TOTALSUM = sum(score1, score2); run;

Output:  

Gender Section score1 score2 totalsum  F A . . .  F B . . . F C . . . M D . . .


Discussion

No Comment Found