- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What is wrong in my code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.