Programming the statistical procedures from SAS

Followup Statistics?

Reply
Occasional Contributor
Posts: 14

Followup Statistics?

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?
Frequent Contributor
Posts: 77

Re: Followup Statistics?

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
Occasional Contributor
Posts: 14

Re: Followup Statistics?

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.
Valued Guide
Valued Guide
Posts: 673

Re: Followup Statistics?

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;
Occasional Contributor
Posts: 14

Re: Followup Statistics?

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.
Ask a Question
Discussion stats
  • 4 replies
  • 77 views
  • 0 likes
  • 3 in conversation