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

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
Barite | Level 11

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
Barite | Level 11
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
Barite | Level 11

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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 7 replies
  • 1981 views
  • 1 like
  • 3 in conversation