BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tony7zxzx
Calcite | Level 5

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;

http://support.sas.com/documentation/cdl/en/proc/68954/HTML/default/viewer.htm#n1affq2dctdc8un1eokb5...

View solution in original post

4 REPLIES 4
Shmuel
Garnet | Level 18

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;

tony7zxzx
Calcite | Level 5

Screen Shot 2016-10-14 at 5.29.29 PM.png

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. 

ballardw
Super User

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;
Reeza
Super User

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;

http://support.sas.com/documentation/cdl/en/proc/68954/HTML/default/viewer.htm#n1affq2dctdc8un1eokb5...

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1067 views
  • 2 likes
  • 4 in conversation