Help using Base SAS procedures

Proc means output with variable name change

Accepted Solution Solved
Reply
Contributor
Posts: 66
Accepted Solution

Proc means output with variable name change

Hi,

I'm running a proc means with stats of MAX and SUM the report may look something like this:

Variable MAX SUM

var1 10 100

var2 5 72

etc.

I was wondering if it is possible to have an output data set that would append the statistic to the end of the variable name?

In this example the output data set would look similar to:

Variable Value

var1_max 10

var1_SUM 100

var2_max 5

var2_SUM 72

etc.

Thanks for your help.


Accepted Solutions
Solution
‎08-04-2011 04:36 PM
Super User
Posts: 19,878

Proc means output with variable name change

Posted in reply to Danglytics

Try the autoname option in your output statement with a proc transpose.

proc means data=sashelp.class noprint;

    var age height weight;

    output out=test max= sum=/autoname;

run;

View solution in original post


All Replies
PROC Star
Posts: 7,492

Proc means output with variable name change

Posted in reply to Danglytics

You could use something like:

data have;

  input Variable $ MAX SUM;

  cards;

var1 10 100

var2 5 72

;

data want (keep=variable value);;

  set have (rename=(variable=var));

  variable=cats(var,"_MAX");

  value=max;

  output;

  variable=cats(var,"_SUM");

  value=sum;

  output;

run;

Solution
‎08-04-2011 04:36 PM
Super User
Posts: 19,878

Proc means output with variable name change

Posted in reply to Danglytics

Try the autoname option in your output statement with a proc transpose.

proc means data=sashelp.class noprint;

    var age height weight;

    output out=test max= sum=/autoname;

run;

Contributor
Posts: 66

Proc means output with variable name change

Thank you, this worked.

🔒 This topic is solved and locked.

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

Discussion stats
  • 3 replies
  • 1132 views
  • 0 likes
  • 3 in conversation