BookmarkSubscribeRSS Feed
jawon
Fluorite | Level 6
The current code...

proc univariate data = my_input_dataset;
var age weight height;
output out = my_output_dataset
median = median
mean = mean
mode = mode
;
run;

So this appears to output the stats for "age", but then overwrites with the stats for "weight", and finally "height". So I only end up with one row containing the stats for the most recent variable.

Can the univariate procedure create a dataset with the stats for all of these variables (ie, without having to throw in some data steps and loop, etc)? In which case, is there a way to throw in the variable name to distinguish the rows?
1 REPLY 1
Cynthia_sas
SAS Super FREQ
Hi:
You have 2 choices:
1) Use Univariate internal OUTPUT syntax to name the variables listed in your VAR statement or
2) Use ODS OUTPUT syntax to get the "BASICMEASURES" output object that will contain all the info for the variables listed in the VAR statement.

cynthia
[pre]
** 1) Use Univariate OUTPUT statement to create multiple variables;
ods trace on /label;
proc univariate data = sashelp.class;
var age weight height;
output out = my_output_dataset
median =medage medwt medht
mean =mnage mnwt mnht
mode =modage modwt modht ;
run;
ods trace off;

ods listing;
proc print data=my_output_dataset;
title '1) Using Internal OUTPUT statement';
run;

** 2) use ODS OUTPUT statement;
ods output basicmeasures=work.all_basic;
proc univariate data = sashelp.class;
var age weight height;
run;

proc print data=work.all_basic;
title '2) Using ODS OUTPUT';
run;
[/pre]

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
  • 1 reply
  • 9793 views
  • 0 likes
  • 2 in conversation