BookmarkSubscribeRSS Feed
dtha2622
Calcite | Level 5

I'm using proc summary to calculate some quintiles, and I'm trying to get it in an output so it's easier to copy and paste across.

 

proc summary data=example min q1 median q3 max print;
var variable_1 variable_2;
output out=example_quintiles;
run;

I ran that and get the results in the format I want printed

Capture.PNG

However I get something completely different in the output data, which makes it more difficult to copy and paste.

Capture2.PNG

Any ideas?

3 REPLIES 3
Kurt_Bremser
Super User

Sadly, the default OUTPUT structure does not honor the statistics set in the PROC MEANS statement, so we need to beat the output into shape:

(using SASHELP.CLASS as an example)

proc summary data=sashelp.class min q1 median q3 max print;
var height weight;
output out=summary min= q1= median= q3= max= / autoname;
run;

proc transpose
  data=summary
  out=long1
;
var height: weight:;
run;

data long2;
set long1;
varname = scan(_name_,1,"_");
stat = scan(_name_,2,"_");
run;

proc transpose
  data=long2
  out=want (drop=_name_)
;
by varname;
var col1;
id stat;
run;
data_null__
Jade | Level 19

You can use ODS and the STACKODS PROC statement option to get this data directly.

ods select none;
proc summary data=sashelp.class min q1 median q3 max print stackods;
   var height weight;
   ods output summary=summary;
   run;
ods select all;
proc print data=summary;
   run;

Capture.PNG

 

 


@Kurt_Bremser wrote:

Sadly, the default OUTPUT structure does not honor the statistics set in the PROC MEANS statement, so we need to beat the output into shape:

(using SASHELP.CLASS as an example)

proc summary data=sashelp.class min q1 median q3 max print;
var height weight;
output out=summary min= q1= median= q3= max= / autoname;
run;

proc transpose
  data=summary
  out=long1
;
var height: weight:;
run;

data long2;
set long1;
varname = scan(_name_,1,"_");
stat = scan(_name_,2,"_");
run;

proc transpose
  data=long2
  out=want (drop=_name_)
;
by varname;
var col1;
id stat;
run;

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 3 replies
  • 1082 views
  • 2 likes
  • 4 in conversation