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
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;
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.
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;
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?
What's wrong with
proc means data=PL(keep=TYPE _:) noprint;
by TYPE;
output out=SUM sum=;
run;
Thanks a lot for your helps.
HHC
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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.