SAS (Base SAS)+
data CLASS;
infile datalines dlm='|' dsd missover;
input Name : $8. Sex : $1. Age : best32. Height : best32. Weight : best32.;
datalines;
Alfred|M|14|69|112.5
Alice|F|13|56.5|84
Barbara|F|13|65.3|98
;
run;
data new_class;
set class;
run;
infile datalines dlm='|' dsd missover;
input Name : $8. Sex : $1. Age : best32. Height : best32. Weight : best32.;
datalines;
Alfred|M|14|69|112.5
Alice|F|13|56.5|84
Barbara|F|13|65.3|98
;
run;
data new_class;
set class;
run;
- To copy a SAS dataset, we write a
DATAstep that names the new dataset, reads from the old one withSET, and runs. data new_class;declares the output.set class;reads every observation of CLASS into new_class one at a time.- No explicit
keepordropstatement means SAS copies every variable unchanged. - The result is a brand-new dataset in the WORK library. Any later edits we make to
new_classdo not affect the originalclass. - This pattern also serves as the starting point for in-place transformations — we copy first, then add derived columns, filter rows, or change formats on the copy.