SAS (Base SAS)+
data CLASS;
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
Alice|F|13|56.5|84
Barbara|F|13|65.3|98
Henry|M|14|63.5|102.5
James|M|12|57.3|83
;;;;
run;
proc summary data=class;
var height ;
output out=stats01 n=n mean=mean std=sd;
run;
proc summary data=class nway;
class sex ;
var height ;
output out=stats02 n=n mean=mean std=sd;
run;proc summary data=class;runs on CLASS;var height;names the analysis variable.output out=stats01 n=n mean=mean std=sd;writes one row with columns namedn,mean, andsd.- For a grouped run, we add
class sex;plus thenwayoption. nwayrestricts the output to the finest-class combinations; without it, SAS would also add overall-total rows we do not want here.- After running, STATS01 should have one overall summary row and STATS02 should have one row per Sex level.
- Open both datasets and confirm the n for STATS02 adds up to the n in STATS01.