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
Diamond | Level 26
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]

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 11412 views
  • 0 likes
  • 2 in conversation