SAS Procedures

Help using Base SAS procedures
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 11028 views
  • 0 likes
  • 2 in conversation