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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

3 REPLIES 3
art297
Opal | Level 21

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;

Reeza
Super User

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;

Danglytics
Calcite | Level 5

Thank you, this worked.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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