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;

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 353 views
  • 2 likes
  • 4 in conversation