BookmarkSubscribeRSS Feed
Phero
Calcite | Level 5
I am still in the process of learning some of the fundamentals of SAS, and I am trying to automate as much as I can. If this question is answered in another thread, then I apologize.

Is it possible to do follow-up procedures based on the output of a previous statistical procedure? For example, say I run a PROC GLM. I want to run a PROC MEANS, however, only if specific p values returned from the PROC GLM is < .05.

How would I go about doing this? How do I get those probability values from the PROC GLM and then use them to inform the program whether or not to perform the following PROC MEANS?
4 REPLIES 4
statsplank
Calcite | Level 5
Hello Phero,

When you run Proc GLM, include the ODS statement to extract the p-values and the corresponding effects (variable names) from the appropriate ODS table. Then, after selecting the variables with p<0.05, you can pass them on to Proc MEANS.

~Olga
Phero
Calcite | Level 5
Thanks for the reply. I have seen a lot of people mention using the ods trace on statement, but to be honest, I haven't been entirely clear as to what the output is that I'm looking at. Is there a good place to start to figure out what and where to ODS tables are, with example code or a breakdown of what the table would be? As I said, I'm still kind of new to SAS, so I'm not used to variables being around that I haven't explicitly declared.

Thanks again for your help.
lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12
Every portion of the output has a corresponding ODS table name. Go to the documentation for GLM and find "ODS Table Names". Using the ODS OUTPUT statement, you can direct SAS to create data files for each desired table within the output. The example below creates the MA file for the Type 1 and 3 test statistics (plus p-values, etc.; with a separate record for type 1 and type 3), and the LS file for the least squares means. Note: the names on the left-hand side of the = come for the ODS Table Names; the names on the right-hand side of = are arbitrary. Using PRINT, you can see how SAS stores the values. With programming steps, you could then delete either the type 1 or type 3 record (depending on the hypothesis you cared about), and then continue with other procedures.

However, I don't know why you would want to use PROC MEANS here, considering that you can easily use the LSMEANS (or even MEANS) statements right in GLM.

data t;
input trt y;
datalines;
1 1
1 2
1 2
2 6
2 5
2 4
3 2
3 3
3 4
;
proc glm data=t;
ods output ModelANOVA=ma LSmeans=ls;
class trt;
model y = trt;
lsmeans trt;
run;
proc print data=ma;
proc print data=ls;
run;
Phero
Calcite | Level 5
Thanks for your reply, that seems to help. I'm still fairly unsophisticated with ODS, so it looks like I've got some work ahead of me in learning all of the ins and outs, as it were.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1593 views
  • 0 likes
  • 3 in conversation