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

Hi, how can I make a summary table like this one:

               mean     median     min     max     std

var1          a             b          c          d          e                

var2          f               g          h          i          j         

var3          k               l          n          o          p

where a,b,c,... is calculated. Now i only have it as one row. also, for the median I have instead of just 1 number a lot of number (all the number of that column).

Thank you very much!

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

You have to declare the statistics that you want.  e.g.:

proc means data=sashelp.class min max mean median stackods;

  var height weight;

  weight age;

  output out=sample_summary median= mean= min= max= stddev= /autoname;

run;

View solution in original post

20 REPLIES 20
art297
Opal | Level 21

It would help to see either your data or a subset of it.  However, what you are looking for is probably proc means.

Take a look at: http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000146729.htm

Reeza
Super User

If you have version 9.3 then try the following:

proc means data=sashelp.class stackods;

var height weight age;

output out=sample_summary;

run;

thdang
Calcite | Level 5

but those means are weighted means. so just want to get the layout or is that also possible to do the weighted means with the proc means

art297
Opal | Level 21

Why do you say they are weighted means?  They would only be weighted means if a weight statement was included for the proc.

thdang
Calcite | Level 5

I mean that the means i want to calculate in my table are weighted mean. So if i do 'proc mean' i would get the normal means right. So i wonder if i can have the weighted means by using 'proc means'.

art297
Opal | Level 21

Yes.  You simply have to include a statement like:

proc means data=sashelp.class stackods;

  var height weight;

  /*->*/ weight age;

output out=sample_summary;

run;

thdang
Calcite | Level 5

proc means data=sasdata.have;

    var avg_return avg_expense avg_turnover ;

    weight weights;

    output out= sasdata.summary_statistics;

run;

"stackods" did not work for me, i think because i have version 9.2. but i don't have the median in the table

art297
Opal | Level 21

You have to declare the statistics that you want.  e.g.:

proc means data=sashelp.class min max mean median stackods;

  var height weight;

  weight age;

  output out=sample_summary median= mean= min= max= stddev= /autoname;

run;

thdang
Calcite | Level 5

Thank you for your help!!

Ksharp
Super User

Very interesting thing, Although the output of proc means looks good , but output dataset does not look right.

filename  x temp;
proc printto print=x; run;
proc means data=sashelp.class min max mean median ;
  var height weight;
  weight age;
run;
proc printto;run;
data want;
 infile x firstobs=7;
 input variable : $40. @;
 if variable not eq: '--' then do;input min max mean median; output;end;
run;

Ksharp

art297
Opal | Level 21

: What doesn't look right to you?

Ksharp
Super User

ArthurT,

My SAS9.2 can't work with option stackods . It looks like ,which might not be what OP want.

data_null__
Jade | Level 19

I think with 9.2 "you" will need to fiddle with the output to get what the OP is looking for.

proc SUMMARY data=sashelp.class;
   var height weight age;
   output out=summary median= mean= min= max= stddev= /autoname;
  
run;
proc transpose data=summary(drop=_type_ _freq_) out=tall;
   run;
data tall;
   set tall;
   length variable $32;
   _ = find(_name_,
'_',-32);
   variable = substr(_name_,1,_-1);
   _name_ =   substr(_name_,_+1);
   run;
proc sort;
  
by variable;
   run;
proc transpose data=tall out=notsotall;
   by variable;
   var col1;
   run;
thdang
Calcite | Level 5

Can I also make summary tables by five year interval (i.e 1980,85,90,95,00..) including the number of unique id in those years? Thank you very much.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 20 replies
  • 2652 views
  • 7 likes
  • 5 in conversation