Thursday, March 13, 2008

Subset data

/*************************************/
/* select observations and variables */
/*************************************/
data subset1;
set admit;
if fee>= 124.80 & sex = 'M';
keep id name age weight;
run;

The KEEP statement specifies that only the variables ID, Name, Age, and Weight appear in the subset data. You can use the DROP statement instead if more variables are kept than dropped.

/*************************************/
/* subset data, perform processing, */
/* and subset variables again */
/*************************************/
data subset2(keep=id sex kgweight);
set admit(drop=name date);
if actlevel='LOW' and age>40;
KgWeight=weight/2.2;
run;

The DROP= data set option in the SET statement prevents the variables Name and Date from being read from the input data set (and therefore from appearing in the output data set).

No comments:

Post a Comment