SAS (Base SAS)+
data MALES;
infile datalines dlm='|' dsd missover;
input Name : $8. Sex : $1. Age : best32. Height : best32. Weight : best32.;
label ;
format ;
datalines4;
Alfred|M|14|69|112.5
Henry|M|14|63.5|102.5
James|M|12|57.3|83
;;;;
run;
data FEMALES;
infile datalines dlm='|' dsd missover;
input Name : $8. Sex : $1. Age : best32. Height : best32. Weight : best32.;
label ;
format ;
datalines4;
Alice|F|13|56.5|84
Barbara|F|13|65.3|98
Carol|F|14|62.8|102.5
;;;;
run;
data class;
set males females;
run;- To append rows in SAS, the classic approach is a DATA step with multiple datasets on the
SETstatement:set class class2;. - SAS reads every observation from
classfirst, then every observation fromclass2, into the output dataset. - Variables with the same name and type are merged automatically. Variables that exist in only one side get missing values for the other side’s rows.
- An alternative is
PROC APPEND base=class data=class2;— it writesclass2onto the end ofclassin place, without creating a new dataset. Useful for very large data where we do not want to duplicate. - After running, the output has all rows from both inputs and every column from either side.