Hi all,
I have the following code:
proc means data=sample5 mean std;
var fare;
output out=sampleX5;
run;
I received the following output:
On the same time I badly need to prepare the following output:
-----------------------------------------------
Sample No | Seed No | Mean | Std |
-----------------------------------------------
| | | |
------------------------------------------------
Is it possible to use any options in mean function to sort it out? Or should I use 'proc transpose' only? Thank you.
Hi all,
Here it is the desicion using the link provided by Reeza.
proc means data=sample&i noprint;
var fare;
output out=sampleX&i(drop=_type_ _freq_) mean= std= / autoname;
run;
data sampleY&i;
length sample_no $2 seed_no $5;
set sampleX&i;
sample_no=&i;
seed_no=&&seed&i;
run;
STACKODS option in your PROC MEAN statement and then use the ODS Table.
http://blogs.sas.com/content/sgf/2015/07/17/customizing-output-from-proc-means/
See the last section of the blog post.
Perhaps something like:
proc summary data=sample5 nway ; class sample seed;
var fare; output out=sampleX5 mean= std= /autoname; run;
You don't provide any variable names in your example that correspond to "sample no" or "seed" so I'm guessing here.
Proc summary does everything that means does with minor differences in some default behaviors. Summary always expects to build an output data set (ancient history Means didn't and summary was it) and will attempt to have statistics in columns not rows however you need to provide output names or use the autoname option which will, in this example, create fare_mean and fare_std. If you have multiple variables with the same requested statistics the basevariable receives a suffix with the statistic to create unique variables.
Hi all,
Here it is the desicion using the link provided by Reeza.
proc means data=sample&i noprint;
var fare;
output out=sampleX&i(drop=_type_ _freq_) mean= std= / autoname;
run;
data sampleY&i;
length sample_no $2 seed_no $5;
set sampleX&i;
sample_no=&i;
seed_no=&&seed&i;
run;
This is a great example of why you should have used a single seed and REP. Then you can just use the BY statement. I think it's still worth stacking them and then processing.
*stack data together;
data have;
set seed1-seed10 indsname=source;
file=source;
run;
*sort to allow for BY. Could do CLASS as well;
proc sort data=have; by file;
proc means data=have nway stackods mean std;
by file;
var fare;
ods output summary=want;
run;
proc print data=want;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.