I was using this code to build a demographic table. How can I use one proc means to complete this.
proc means data=Work.aa;
var bwt;
class sex;
run;
proc means data=Work.aa;
var bwt;
class crace;
run;
proc means data=Work.aa;
var bwt;
class msmoke;
run;
proc means data=Work.aa;
var bwt;
class pvprem;
run;
proc means data=Work.aa;
var bwt;
class newmeduc;
run;
Use the WAYS or TYPES statement. WAYS is easier in this case. If you don't specify WAYS or TYPES you get all levels of analysis and then it's hard to filter out what you want.
proc means data=Work.aa;
class sex crace msmoke pvprem newmeduc;
WAYS 1; *says only 1 level analysis;
var bwt;
run;
You can try:
proc means data=Work.aa NWAY /* options: missing noprint ? */ ;
class sex crace bwt msmoke pvperm newmeduc;
var bwt;
/* optionally add and look at the output dataset my_stat */
output out=my_stat /* ... list of statistics desired */ ;
run;
Bwt is a continues variable.
All my 5 virable after class are categorical variable.
I use my code to get 5 tables like this. I am trying to use some options in proc means to generate 5 table.
If you are looking for this in one table another option would be one of the report procedures such as Tabulate or Report
here's a Tabulate example:
proc tabulate data=work.aa;
class sex crace msmoke pvprem newmeduc/missing;
var bwt;
table sex crace msmoke pvprem newmeduc,
bwt*(n mean std Min Max);
run;
Use the WAYS or TYPES statement. WAYS is easier in this case. If you don't specify WAYS or TYPES you get all levels of analysis and then it's hard to filter out what you want.
proc means data=Work.aa;
class sex crace msmoke pvprem newmeduc;
WAYS 1; *says only 1 level analysis;
var bwt;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.