Help using Base SAS procedures

Proc Mean Output Rename & put variables new table

Accepted Solution Solved
Reply
Super Contributor
Posts: 395
Accepted Solution

Proc Mean Output Rename & put variables new table

At the following code i don't want to change columns name when i use to output option .How can i prevent this. And i wonder if i need to use more VAR variable im Mean procedure how can i do it. If i do it, is it possible to make sort this values on new table ?

Thank you.

 

PROC MEANS DATA=WORK.X1 noprint
FW=12
PRINTALLTYPES
CHARTYPE
QMETHOD=OS
VARDEF=DF
MEAN
STD
MODE
P10
P90 ;
VAR F2;
ods output summary=sample;
RUN;
data newStep;
set work.sample;
Slope=2.95/(((F2_P90-F2_Mode)*2+F2_Mode)-(F2_Mode));
Median=((F2_P90-F2_Mode)*2+F2_Mode)-((F2_Mode)-(F2_P90-F2_Mode)*2)/2;
run;


Accepted Solutions
Solution
‎09-25-2015 06:23 AM
Super User
Posts: 19,767

Re: Proc Mean Output Rename & put variables new table

Several ways
1) var q1-q1000;
2) var q:;
3) var q1--q1000; used when variables are listed side by side but not necessarily all present or in order.

View solution in original post


All Replies
Trusted Advisor
Posts: 1,137

Re: Proc Mean Output Rename & put variables new table

did you try the autoname= option in proc meand. This automatically rename the new variables created by concatenating the statistical var with var statement variable. So the new variables will be named as mean_f2. Hope this is what you are expecting.
Thanks,
Jag
Trusted Advisor
Posts: 1,137

Re: Proc Mean Output Rename & put variables new table

you can use more var variables in proc means by just mentioning the numeric variable names in the var statement separated by space. And in the output out statement , use the autoname option so that the descriptic statistics produced will represent the respective statistics concatenated with variable names.Try the code something like below

 

proc means data=have mean std min max;
var var1 var2;
output out=want mean= std= min= max= / autoname;
run;

Thanks,

Jag

Thanks,
Jag
Super Contributor
Posts: 395

Re: Proc Mean Output Rename & put variables new table

Posted in reply to Jagadishkatam

Thanks a lot but how can i prevent first two column and it brings just one raw in output?

proc means data=SampleData mean std mode P10 P90
FW=12  
	PRINTALLTYPES
	CHARTYPE
	QMETHOD=OS
	VARDEF=DF 	
		MEAN 
		STD 
		MODE 	
		P10 
		P90
 ;
var Q1 Q2;
output out=want mean=mean std=std mode=mode P10=P10 P90=P90;
run;

data newsample;
set work.sample;
Slope=2.95/(((P90-Mode)*2+Mode)-(Mode));
Median=((P90-Mode)*2+Mode)-((Mode)-(P90-Mode)*2)/2;
run;

nolabel.png

I need other columns here ?

 

&

 

If i need to add thousands VAR in the proc means procedure  how can i made it ?

 

Thank you.

 

 

Super Contributor
Posts: 395

Re: Proc Mean Output Rename & put variables new table

I'll take thousands column and I want to see output like this.

.output.png

Super User
Posts: 11,335

Re: Proc Mean Output Rename & put variables new table

You can get all numeric variables on the VAR statement using a special list: _numeric_

 

as in

VAR _numeric_;

 

Or NO VAR statement at all will summarize all numeric variables in the data.

 

 

 

 

Super User
Posts: 19,767

Re: Proc Mean Output Rename & put variables new table

Super Contributor
Posts: 395

Re: Proc Mean Output Rename & put variables new table

Thanks again but I tried it and it didn't work.

Super User
Posts: 19,767

Re: Proc Mean Output Rename & put variables new table

That's not helpful. How did it not work? What was your code? What does your data look like and what output do you want? Was there any errors?
Super Contributor
Posts: 395

Re: Proc Mean Output Rename & put variables new table

I tried again and i made it, thank you. Now my last question is how can i add thousands columns on VAR expression from another data set.

proc means data=WORK.sample STACKODS
FW=12
     PRINTALLTYPES
     CHARTYPE
     QMETHOD=OS
     VARDEF=DF 
           MEAN 
           STD 
           MODE    
           P10 
           P90 ;
var Q1 Q2 Q3;
ods output summary=stacked;
run;
/*This code gives multiple row output*/



%let number=????
proc means data=WORK.sample STACKODS
FW=12
     PRINTALLTYPES
     CHARTYPE
     QMETHOD=OS
     VARDEF=DF 
           MEAN 
           STD 
           MODE    
           P10 
           P90 ;
var Q1 Q2 Q3........Q10000;
ods output summary=stacked;
run;

 

 

Solution
‎09-25-2015 06:23 AM
Super User
Posts: 19,767

Re: Proc Mean Output Rename & put variables new table

Several ways
1) var q1-q1000;
2) var q:;
3) var q1--q1000; used when variables are listed side by side but not necessarily all present or in order.
Super Contributor
Posts: 395

Re: Proc Mean Output Rename & put variables new table

Thanks a lot. I made it. Smiley Happy

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 11 replies
  • 1390 views
  • 0 likes
  • 4 in conversation