## Proc Summary Help!

Solved
Occasional Contributor
Posts: 15

# Proc Summary Help!

I intend to create the following statistics  for some continuous variable. I used Proc summary as follow

``````proc summary data=&dataset nway completetypes;
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
Solution
‎08-29-2016 08:49 AM
Posts: 3,852

## Re: Proc Summary Help!

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;``````

All Replies
Super User
Posts: 5,888

## Re: Proc Summary Help!

Occasional Contributor
Posts: 15

## Re: Proc Summary Help!

I tried by listing the keywords for the statistics I want, no luck. It only produces statistics for one variable.
What is wrong in my code?
Solution
‎08-29-2016 08:49 AM
Posts: 3,852

## Re: Proc Summary Help!

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;``````
Super User
Posts: 10,787

## Re: Proc Summary Help!

```
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;

```
Posts: 3,852

## Re: Proc Summary Help!

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.

☑ This topic is solved.