## Extracting variables from statistical results for use in other calculations

Solved
Occasional Contributor
Posts: 8

# Extracting variables from statistical results for use in other calculations

Greetings!

I frequently use proc GLM for repeated measures ANOVA and more recently proc corr for correlational work.  In the case of proc GLM I would like to extract various sums of squares and degrees of freedom for other calculations, such power, effect size or ICC.  In the case of the proc corr I would like to extract specific correlations in a matrix for further calculations such as confidence intervals or hypothesis testing of different correlation coefficients.

Is there a reference(s) where I can learn how to do this.  Or a website of examples I can use to learn how to do this type of programming.  I am getting bits and pieces as I search the web but there are gaps that make it impossible for me to figure it out on my own.

Best Wishes,

dg

Accepted Solutions
Solution
3 weeks ago
Regular Contributor
Posts: 161

## Re: Extracting variables from statistical results for use in other calculations

All Replies
Solution
3 weeks ago
Regular Contributor
Posts: 161

## Re: Extracting variables from statistical results for use in other calculations

Occasional Contributor
Posts: 8

## Re: Extracting variables from statistical results for use in other calculations

Hello.  Thank you.  That looks pretty darn close.  I will have to read it tomorrow morning.  Once the variables are extracted, examples have thing "&" in front of the extracted variables and the word "symput".   The link is one missing piece; that is, how to identify them to extract them.  Thanks once again.

dg

Regular Contributor
Posts: 161

## Re: Extracting variables from statistical results for use in other calculations

[ Edited ]

a very common example is when we need to give the sample size (n) in the table column headings. The code would be something like this (we use "&" because we are making the statistic a macro variable so we can use it elsewhere eg when creating the table or figure):

ods output onewayfreqs=getn;

proc freq data=temp;

tables treatment;

run;

data _null_;

set getn;

if treatment=1 then call symput("trt11",strip(put(frequency,2.)));

else if treatment=2 then call symput("trt2",strip(put(frequency,2.)));

run;

proc report data=....;

column .... trt1 trt2 ....;

:

define trt1 / display width=10 right "Treatment 1 (n=&trt1)";

define trt2 / display width=10 right "Treatment 2 (n=&trt2)";

:

run;

--------------
blog: papersandprograms.com
Occasional Contributor
Posts: 8

## Re: Extracting variables from statistical results for use in other calculations

PaulBrown,

The example is exactly the type of thing talking about.  I can read the code and see exactly what what you are doing.  I have been using SAS for a long time but only for straight forward text book examples.  No coding.  I so most of my data manipulation like that in MATLAB which learned it organically over 30 years.  Now, I am trying to do the same with SAS programming to minimize going back and fourth between programs.  That is, use SAS for statistics then type in the results into code written MATLAB for further analysis.  The code below illustrates what I am trying to accomplish from beginning to end.  Now, I have to apply to ANOVA and correlational work.

Best Wishes,

dg

Posts: 5,529

## Re: Extracting variables from statistical results for use in other calculations

If you see the required value in the procedure output, you can get it in an ODS table. Check the Details section of the procedure documentation for the ODS Table Names topic. Add the statement

ODS OUTPUT procTablename=myTableName;

to your code and look at the table contents. The value will be there somewhere.

PG
Occasional Contributor
Posts: 8

## Re: Extracting variables from statistical results for use in other calculations

Thank you very much.

dg
Super User
Posts: 23,724

## Re: Extracting variables from statistical results for use in other calculations

Occasional Contributor
Posts: 8

## Re: Extracting variables from statistical results for use in other calculations

Thank is a great reference for the thing I am trying to do.

dg
☑ This topic is solved.