BookmarkSubscribeRSS Feed
BrentFulton
Calcite | Level 5

Hi,

I would like to write SAS code so output from procedures is automatically put into a table. For example, if I run proc means data=data1 mean N NMISS on 15 variables, I would like the output to go into a table with four columns (variable name, mean, N, NMISS) and 15 rows (one for each variable). Is that possible? I can do this in Stata, because all output is stored in scalars and matrices, which can be accessed and put into a matrix (i.e., table) that I create.

Thanks,

Brent Fulton

UC Berkeley

4 REPLIES 4
Howles
Quartz | Level 8

See

http://www.sascommunity.org/wiki/PROC_MEANS_-_Improve_on_the_default

BrentFulton wrote:

Hi,

I would like to write SAS code so output from procedures is automatically put into a table. For example, if I run proc means data=data1 mean N NMISS on 15 variables, I would like the output to go into a table with four columns (variable name, mean, N, NMISS) and 15 rows (one for each variable). Is that possible? I can do this in Stata, because all output is stored in scalars and matrices, which can be accessed and put into a matrix (i.e., table) that I create.

Thanks,

Brent Fulton

UC Berkeley

data_null__
Jade | Level 19

Be aware that the last time I looked this program did not produce 2-sided confidence intervals as you would expect when both are Upper and Lower CI are requested.

Tom
Super User Tom
Super User

Almost all procedure will now deliver the output into datasets for you using the ODS output system. 

http://support.sas.com/documentation/cdl/en/odsug/62755/HTML/default/viewer.htm

Also many procedures have options to specify output datasets.

In particular for PROC MEANS/SUMMARY there is the OUTPUT statement.

Peter_C
Rhodochrosite | Level 12

Tom

before SAS9.3, ODS OUTPUT wasn't generating the layout that seemed natural in the output window (and I'm not sure if it will now - in 9.3). So Myra Olstik started her project to automate the process of creating a column for each variable with a row for each requested statistic.The results of that project are described in a paper with the macro code, that can be found at the link offered above, by Howles http://www.sascommunity.org/wiki/PROC_MEANS_-_Improve_on_the_default

As you suggest, the solution uses the output statement (one for each statistic).

peterC

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 4 replies
  • 804 views
  • 0 likes
  • 5 in conversation