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

Hi,

I want to run a proc means for a list of variables that start with _

 

	proc means data=PL noprint;
	var _:;
	by type;
	output out=PL_sum
	sum= _:;
	run;

The problem is with SUM=_:

Is there any way to let SAS keep the original name for variable in output file?

Thank you,

HC

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

You don't need that. Your original code was correct, you just needed to not list any variables in the SUM statement, since you'd already done so in the VAR statement.

proc means data=class SUM noprint;
	by sex;
	var weight height age;
	output out=want sum=;
run;

proc print data=want;
run;

View solution in original post

7 REPLIES 7
Reeza
Super User

1. Check if the ODS tables work better for you. 

2. There is the AUTONAME option but it ends up being the variable_statistic type format. It may work for you, but it isn't the original variable name.

hhchenfx
Rhodochrosite | Level 12

Thanks,

 

I use that ODS and Transpose to get what I want.

 

However, there is a minor issue related to the number format.

 

In the TEMP_ file, some numbers are 2 decimal place, some are rounded.

 

Is there anyway to choose the format of the number in the TEMP_File?

 

Thanks

 

HC

 


ods listing close;
ods output summary=TEMP_;
proc means data=PL stackods SUM;
	by Type;
run;
ods output close;
ods listing;
run;

proc transpose data=TEMP_ out=WANT ;
by Type;
var sum;
id variable;
run;
Reeza
Super User

Apply a format to the new variables. Most likely the underlying variables have the decimal values as well. 

 

Usually you use STACKODS and don't transpose or don't use STACKODS. 

Did not using STACKODS give you what you want directly?

hhchenfx
Rhodochrosite | Level 12
Nice, No stackods is better.
But the name ending with _sum, which is understandable.
Is there any way to get rid of that _SUM all together? It is not efficient to write 30 rename.

HC
ChrisNZ
Tourmaline | Level 20

What's wrong with

 


proc means data=PL(keep=TYPE _:) noprint;
  by TYPE;
  output out=SUM sum=;
run;
hhchenfx
Rhodochrosite | Level 12

Thanks a lot for your helps.

HHC

Reeza
Super User

You don't need that. Your original code was correct, you just needed to not list any variables in the SUM statement, since you'd already done so in the VAR statement.

proc means data=class SUM noprint;
	by sex;
	var weight height age;
	output out=want sum=;
run;

proc print data=want;
run;

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 2873 views
  • 1 like
  • 3 in conversation