BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DmytroYermak
Lapis Lazuli | Level 10

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.

1 ACCEPTED SOLUTION

Accepted Solutions
DmytroYermak
Lapis Lazuli | Level 10

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;

View solution in original post

5 REPLIES 5
Reeza
Super User

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.

DmytroYermak
Lapis Lazuli | Level 10
Thank you, Reeza. It seems that it will take some time to be familiarized with 'STACKODS'. I used you link in my decision. It is following.
ballardw
Super User

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.

DmytroYermak
Lapis Lazuli | Level 10

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;
Reeza
Super User

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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

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
  • 5 replies
  • 4950 views
  • 8 likes
  • 3 in conversation