SAS Enterprise Guide

Desktop productivity for business analysts and programmers
BookmarkSubscribeRSS Feed
bendsteel6
Obsidian | Level 7

Hi,

I'm using SAS EG and doing a Historgram using PROC UNIVARIATE (SAS EG 6.1 running SAS 9.2 TS2M3 on LINUX).  I'm suppressing the actual charts but putting the output variables to a table (mean, std, median, var, etc). Is there a way to format these output variables to something like 8.2 or the like in the actual PROC itself?  I could create another datastep to do this but I don't want to add another step. There's probably no way using the actual Distribution 'node' in EG, but maybe just using the SAS code for PROC UNIVARIATE?

 

Thanks,

Dave

11 REPLIES 11
ChrisHemedinger
Community Manager

You can modify the output template using PROC TEMPLATE.  @Bari_sas recently shared an example that might be really useful for you.

Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!
bendsteel6
Obsidian | Level 7
Hi Chris,
I'll check this out. I'm very much a novice with PROC TEMPLATE. Been writing code for 23 years...never used PROC TEMPLATE. 😞
Thanks!
bendsteel6
Obsidian | Level 7

Hi,

I'm using SAS EG and doing a Historgram using PROC UNIVARIATE (SAS EG 6.1 running SAS 9.2 TS2M3 on LINUX).  I'm suppressing the actual charts but putting the output variables to a table (mean, std, median, var, etc). Is there a way to format these output variables to something like 8.2 or the like in the actual PROC itself?  I could create another datastep to do this but I don't want to add another step. There's probably no way using the actual Distribution 'node' in EG, but maybe just using the SAS code for PROC UNIVARIATE?

 

Thanks,

Dave

Reeza
Super User

When you switch to SAS 9.3+ you can use STACKODS in proc means, but before that I think you're stuck with manipulating the data 😞

 

 

bendsteel6
Obsidian | Level 7
Hi Reeza,
Ok, thanks!
ChrisHemedinger
Community Manager

Here's an example of STACKODSOUTPUT (scroll way down in the blog for explanation).  Code:

 

/* Use the STACKODSOUTPUT option on the PROC MEANS statement   */
/* and use the ODS OUTPUT statement to create output data set. */
 
ods output summary=with_stackods(drop=_control_);
proc means data=sashelp.class stackodsoutput sum mean std nway;
 class sex;
 var height weight;
run;
 
proc print data=with_stackods noobs;
 title 'Output data set with STACKODSOUTPUT';
run;
Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!
Rick_SAS
SAS Super FREQ

An alternative to STACKODS output is to use the OUTTABLE= option in PROC UNIVARIATE. This enables you to write all descritive statistics to a SAS data set with minimal effort.  It is eons old, so it is surely included in whatever version of SAS you are running. For an example, see the article "Save descriptive statistics for multiple variables in a SAS data set."

 

Remember, too, that you don't need to use a DATA step to change the format for some variable.  You can use the FORMAT statement in any SAS procedure to temprarily assign a format to a variable for the duration of that procedure. For example:

proc print data=have;

format x y z 8.2;

var x y z;

run;

 

bendsteel6
Obsidian | Level 7
Excellent...thanks!
TomKari
Onyx | Level 15

If you do end up using PROC TEMPLATE, I was in the same position as you about 6 months ago. The SAS documentation isn't bad, but I found what really helped was googling whatever the particular thing I was trying to do. There's a huge number of absolutely fantastic SGF papers that solved (almost) every problem I had.

 

Tom

bendsteel6
Obsidian | Level 7
Hi Tom,
That EXCELLENT...and good to know. I need to start familiarizing myself with that stuff 🙂
Reeza
Super User

To add to Tom's great suggestion, search on lexjansen.com to limit your search to SAS papers.

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!

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 11 replies
  • 5314 views
  • 2 likes
  • 5 in conversation