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
You can modify the output template using PROC TEMPLATE. @Bari_sas recently shared an example that might be really useful for you.
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
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 😞
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;
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;
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
To add to Tom's great suggestion, search on lexjansen.com to limit your search to SAS papers.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.