BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Dorota_Jarosz
Obsidian | Level 7

Expanding on Linlin's ideas and assuming SAS version 9.1 and no SAS/Access to PC Files:


proc means data = sashelp.class noprint;
var age ;
    OUTPUT OUT=dat1 (drop=_:) q1=q1 q3=q3 qrange=qrange ;
run;
proc means data = sashelp.class noprint;
var height ;
    OUTPUT OUT=dat2 (drop=_:) q1=q1 q3=q3 qrange=qrange ;
run;
proc means data = sashelp.class noprint;
var weight ;
    OUTPUT OUT=dat3 (drop=_:) q1=q1 q3=q3 qrange=qrange ;
run;
data want;
length item $ 10;
  set dat1;
  item="age";
  output;
  set dat2;
  item="height";
  output;
  set dat3;
  item="weight";
  output;
run;
proc print;run;
*output:
Obs    item       q1      q3     qrange

1     age       12.0    15.0       3
2     height    57.5    66.5       9
3     weight    84.0    112.5     28.5
;

*old fashion CSV output to flat file;
filename csv "C:\temp\Quartiles.csv";
data _null_;
set want;
file csv;
if _n_=1 then
put @1 "Variable,"
    @12 "q1,"
    @22 "q3,"
    @32 "qrange"
    ;
put @1  item      ","
    @12 q1 best8. ","
    @22 q3 best8. ","
    @32 qrange best8.
    ;
run;


MikeZdeb
Rhodochrosite | Level 12

hi ... rather than use a data step to assemble the data after MEANS, how about using a data step prior to SUMMARY and running it once ...

data class (keep=variable value) / view=class;

set sashelp.class;

array nm(*) _numeric_;

do j=1 to dim(nm);

   variable = vname(nm(j));

   value = nm(j);

   output;

end;

run;

proc summary data=class nway;

class variable;

var value;

output out=stats (drop=_:) q1=q1 q3=q3 qrange=qrange;

run;

variable     q1       q3     qrange

Age        12.0     15.0      3.0

Height     57.5     66.5      9.0

Weight     84.0    112.5     28.5

* create CSV file without ACCESS to PC Files module;

ods csv file='z:\stats.csv';

proc print data=stats noobs;

run;

ods csv close;

Dorota_Jarosz
Obsidian | Level 7

Thank you, MIke. I really like your solution. My mind is still in the mainframe and flat file mode.

Hawkeye
Calcite | Level 5

I ended up geting sas 9.3 so I was able to use the stackods option, thank you all for the help.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 18 replies
  • 15146 views
  • 2 likes
  • 7 in conversation