BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MaryA_Marion
Lapis Lazuli | Level 10

 

proc glm data=&data;
class &indvar;
model &depvar=&indvar;
means &indvar / hovtest=bf;
means &indvar / hovtest=ob;
means &indvar / hovtest=levene;
means &indvar / hovtest=bartlett;
means &indvar / welch;
ods exclude nobs classlevels OverallAnova FitStatistics modelANOVA means boxplot;

In the code above I want to keep only first boxplot. I am having a syntax problem. Can you help? 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

ODS TRACE ON is the key here.

First, run the procedure without using the ODS EXCLUDE statement. The log will show the namves for all the tables and graphs that are produced. Find the one that you want, which I assume is the ANOVA boxplot, which will look something like this:

 

Output Added:
-------------
Name: BoxPlot
Label: Box Plot
Template: Stat.GLM.Graphics.FitBoxPlot
Path: GLM.ANOVA.<NameOfDepVar>.BoxPlot
-------------

You can then use ODS SELECT to select only that graph, as shown in the following example:

 

%let data = sashelp.cars;
%let depvar = mpg_city;
%let indvar = origin;
ods trace on;
proc glm data=&data;
class &indvar;
model &depvar=&indvar;
means &indvar / hovtest=bf;
means &indvar / hovtest=ob;
means &indvar / hovtest=levene;
means &indvar / hovtest=bartlett;
means &indvar / welch;
ods exclude nobs classlevels OverallAnova FitStatistics modelANOVA means boxplot;
ods select GLM.ANOVA.&depVar..BoxPlot;
run;
quit;

View solution in original post

10 REPLIES 10
sbxkoenk
SAS Super FREQ

Hello,

 

Is your data set so big that you cannot afford to do 2 PROC GLM's??

 

You can do something like the below :

%LET depvar=Sales;
%LET indvar=Product;

proc glm data=sashelp.shoes;
class &indvar;
model &depvar=&indvar;
means &indvar / hovtest=bf;
ods exclude nobs classlevels OverallAnova FitStatistics modelANOVA means;
run;

proc glm data=sashelp.shoes;
class &indvar;
model &depvar=&indvar;
means &indvar / hovtest=ob;
means &indvar / hovtest=levene;
means &indvar / hovtest=bartlett;
means &indvar / welch;
ods exclude nobs classlevels OverallAnova FitStatistics modelANOVA means boxplot;
run;
/* end of program */

Koen

MaryA_Marion
Lapis Lazuli | Level 10

I am preparing for big data. So yes is my answer. Someone helped me with a similar problem and I have lost our communications. I will keep looking for it. I have another  similar question. How do I save only a specified number of rows of output. See attachment. This is a table from proc mixed labelled lsmeans. Thank you for your reply. 

MaryA_Marion
Lapis Lazuli | Level 10
You got us started here with a very good set of code.
Rick_SAS
SAS Super FREQ

ODS TRACE ON is the key here.

First, run the procedure without using the ODS EXCLUDE statement. The log will show the namves for all the tables and graphs that are produced. Find the one that you want, which I assume is the ANOVA boxplot, which will look something like this:

 

Output Added:
-------------
Name: BoxPlot
Label: Box Plot
Template: Stat.GLM.Graphics.FitBoxPlot
Path: GLM.ANOVA.<NameOfDepVar>.BoxPlot
-------------

You can then use ODS SELECT to select only that graph, as shown in the following example:

 

%let data = sashelp.cars;
%let depvar = mpg_city;
%let indvar = origin;
ods trace on;
proc glm data=&data;
class &indvar;
model &depvar=&indvar;
means &indvar / hovtest=bf;
means &indvar / hovtest=ob;
means &indvar / hovtest=levene;
means &indvar / hovtest=bartlett;
means &indvar / welch;
ods exclude nobs classlevels OverallAnova FitStatistics modelANOVA means boxplot;
ods select GLM.ANOVA.&depVar..BoxPlot;
run;
quit;
MaryA_Marion
Lapis Lazuli | Level 10

The following code does not create the boxplot. This is the direction I am going in for the solution.


@Rick_SAS wrote:

ODS TRACE ON is the key here.

First, run the procedure without using the ODS EXCLUDE statement. The log will show the namves for all the tables and graphs that are produced. Find the one that you want, which I assume is the ANOVA boxplot, which will look something like this:

 

Output Added:
-------------
Name: BoxPlot
Label: Box Plot
Template: Stat.GLM.Graphics.FitBoxPlot
Path: GLM.ANOVA.<NameOfDepVar>.BoxPlot
-------------

You can then use ODS SELECT to select only that graph, as shown in the following example:

 

%let data = sashelp.cars;
%let depvar = mpg_city;
%let indvar = origin;
ods trace on;
proc glm data=&data;
class &indvar;
model &depvar=&indvar;
means &indvar / hovtest=bf;
means &indvar / hovtest=ob;
means &indvar / hovtest=levene;
means &indvar / hovtest=bartlett;
means &indvar / welch;
ods exclude nobs classlevels OverallAnova FitStatistics modelANOVA means boxplot;
ods select GLM.ANOVA.&depVar.BoxPlot;
run;
quit;

The following is not working:

%let data = sashelp.cars;
%let depvar = mpg_city;
%let indvar = origin;
ods trace on;
proc glm data=&data;
class &indvar;
model &depvar=&indvar;
means &indvar / hovtest=bf;
means &indvar / hovtest=ob;
means &indvar / hovtest=levene;
means &indvar / hovtest=bartlett;
means &indvar / welch;
ods select GLM.ANOVA.&depVar.BoxPlot where = (_path_ ?  'Step1');
run; quit;

Log:

WARNING: Output 'where=(_path_ contains 'Step1')' was not created.  Make sure that the output object name, label, or path is spelled correctly.  
          Also, verify that the appropriate procedure options are used to produce the requested output object.  For example, verify that the NOPRINT 
          option is not used.
 WARNING: Output 'GLM.ANOVA.mpg_cityBoxPlot' was not created.  Make sure that the output object name, label, or path is spelled correctly.  Also, 
          verify that the appropriate procedure options are used to produce the requested output object.  For example, verify that the NOPRINT option 
          is not used.
sbxkoenk
SAS Super FREQ

Hello,

 

Your ODS SELECT statement is wrong.

It should be :

ods select GLM.ANOVA.&depVar..BoxPlot where = (_path_ ?  'Step1');

Thus ... two dots behind &depvar

, one dot as a delimiter for the macro variable (resolution) and one dot as a separator with the string 'BoxPlot'.

 

Koen

MaryA_Marion
Lapis Lazuli | Level 10
That statement is not working for me. I am not sure why. I am checking the ODS users guide.
Rick_SAS
SAS Super FREQ

For anyone wondering what the OP is doing with the WHERE clause, see the article, "Select ODS tables by using wildcards and regular expressions in SAS."

MaryA_Marion
Lapis Lazuli | Level 10

The two dots before boxplot are important.

I want to completely stop outputting any of the means tables. I am doing the following:

%let data = sashelp.cars;
%let depvar = mpg_city;
%let indvar = origin;
ods trace on;
proc glm data=&data;
class &indvar;
model &depvar=&indvar;
means &indvar / hovtest=bf;
means &indvar / hovtest=ob;
means &indvar / hovtest=levene;
means &indvar / hovtest=bartlett;
means &indvar / welch;
ods select GLM.Means.Origin.Means HOVFTest GLM.ANOVA.&depVar..BoxPlot;
run; quit;

Results:
GLM.Means.Origin.Means does not stop displaying Means table.
I only want the ANOVAS FOR THE Tests of Homogeneity to print out
+ one boxplot which is outputting successfully now. How to stop the output of the means plots? Thanks.


Thank you.

MaryA_Marion
Lapis Lazuli | Level 10

Well I have tried various configurations and this is what I have come up with (all run successfully)

 

ods exclude nobs classlevels OverallAnova FitStatistics modelANOVA means boxplot; *anovas only;
ods select GLM.ANOVA.&depVar..BoxPlot where = (_path_ ? 'Step1'); *boxplot only;
ods select GLM.ANOVA.&depVar..BoxPlot where = (_path_ ? 'Step1') HOVfTest; *boxplot+anova;

Its been a great discussion. .. MM 

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
  • 10 replies
  • 1657 views
  • 2 likes
  • 3 in conversation