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
However I get something completely different in the output data, which makes it more difficult to copy and paste.
Any ideas?
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;
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;
@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;
Copy and Paste what?
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!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: