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.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
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;
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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