I intend to create the following statistics for some continuous variable. I used Proc summary as follow
proc summary data=&dataset nway completetypes;
class &grp/ preloadfmt;
var &continuous;
output out=continuous2(drop=_type_);
run;
this was my output.
ths
Is there any way to add to the same table the quantiles(Q1, Median and Q3)?
thanks
You can add output statements for each new statistic and the combine, this make the syntax easy.
I used to do that but with PROC MEANS STACKODS I prefer that option. While the data structure is not the same it is equally useful.
proc summary nway data=sashelp.class;
class sex;
var _numeric_;
output out=stats;
output out=median median=;
output out=q1 q1=;
output out=q3 q3=;
run;
data stats;
set stats median q1 q3 indsname=indsname;
by sex;
if missing(_stat_) then _stat_=scan(indsname,-1,'.');
run;
proc print;
run;
ods exclude all;
proc means data=sashelp.class n mean std min max median q1 q3 nway stackods;
class sex;
ods output summary=summary;
run;
ods exclude none;
proc print;
run;
You can add output statements for each new statistic and the combine, this make the syntax easy.
I used to do that but with PROC MEANS STACKODS I prefer that option. While the data structure is not the same it is equally useful.
proc summary nway data=sashelp.class;
class sex;
var _numeric_;
output out=stats;
output out=median median=;
output out=q1 q1=;
output out=q3 q3=;
run;
data stats;
set stats median q1 q3 indsname=indsname;
by sex;
if missing(_stat_) then _stat_=scan(indsname,-1,'.');
run;
proc print;
run;
ods exclude all;
proc means data=sashelp.class n mean std min max median q1 q3 nway stackods;
class sex;
ods output summary=summary;
run;
ods exclude none;
proc print;
run;
proc univariate data=sashelp.class outtable=want noprint; class sex; var age weight height; run; proc sort data=want; by sex _var_;run; proc print noobs label;run;
@Ksharp wrote:
proc univariate data=sashelp.class outtable=want noprint; class sex; var age weight height; run; proc sort data=want; by sex _var_;run; proc print noobs label;run;
PROC UNIVARIATE does not support PRELOADFMT and has other CLASS statement limitations.
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.
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.