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?
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.
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.
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.
input trt y;
proc glm data=t;
ods output ModelANOVA=ma LSmeans=ls;
model y = trt;
proc print data=ma;
proc print data=ls;