0

I am not sure if what I am trying to do is even possible, so I thought I would check with more experienced SAS users.

I want to run Proc GLM many, many times using the "by" statement and then have output parameters for each run go into a single a file. The output parameters are something like a, b, # points, and R2.

Is this possible?

Thank you!!

Cae.rich
  • 171
  • 7

1 Answers1

0

You can output the results from proc glm in a (several) table(s).

To retrieve the output of proc glm, one can use the ods trace statement to track the object(s) output of proc glm. For more information, please consider reading the ODS TRACE Statement documentation.

proc glm output 6 objects: NObs, OverallANOVA, FitStatistics, ModelANOVA, ModelANOVA and ParameterEstimates.

29         ods trace on;
30         proc glm data=sashelp.cars;
31          model length = mpg_city ;
32         quit;


Output Added:
-------------
Name:       NObs
Label:      Number of Observations
Template:   STAT.GLM.NObsNotitle
Path:       GLM.Data.NObs
-------------

Output Added:
-------------
Name:       OverallANOVA
Label:      Overall ANOVA
Template:   stat.GLM.OverallANOVA
Path:       GLM.ANOVA.Length.OverallANOVA
-------------

Output Added:
-------------
Name:       FitStatistics
Label:      Fit Statistics
Template:   stat.GLM.FitStatistics
Path:       GLM.ANOVA.Length.FitStatistics
-------------

Output Added:
-------------
Name:       ModelANOVA
Label:      Type I Model ANOVA
Template:   stat.GLM.Tests
Path:       GLM.ANOVA.Length.ModelANOVA
-------------

Output Added:
-------------
Name:       ModelANOVA
Label:      Type III Model ANOVA
Template:   stat.GLM.Tests
Path:       GLM.ANOVA.Length.ModelANOVA
-------------

Output Added:
-------------
Name:       ParameterEstimates
Label:      Solution
Template:   stat.GLM.Estimates
Path:       GLM.ANOVA.Length.ParameterEstimates
-------------

I induce that by a,b and # points you are pointing to the estimate parameter that can be found in the ParameterEstimates object. The coefficient of determination however can be found in the FitStatistics object.

Let's say you want to run many proc glm and append the results in a single table (actually two, considering that you will end up with one table for the estimates and one for the coefficients of determination). You can create a macro that will take the result of each proc glm and append it to a table.

%macro glm(y, x);
ods output ParameterEstimates=temp_parameters FitStatistics=temp_fit;

proc glm data=sashelp.cars;
    model &y. = &x. ;
quit;


proc append data=temp_parameters base=parameters;run;
proc append data=temp_fit base=fit;run;

proc datasets lib=work nolist nodetails; delete temp_:;run;
%mend;

%glm(length, mpg_city);
%glm(length, cylinders);
%glm(length, weight);

The two final tables are created, one populated with the estimates (parameters table) and one populated with the coefficient of determination (fit table).

parameters table:

enter image description here

fit table:

enter image description here

Unfortunately, without more information about your problem and no data, I can't assist further.

Kermit
  • 3,112
  • 2
  • 10
  • 34
  • Thank you! This is exactly what I was looking for. I will give it a try and if I can't get it to work I will edit my question to include a subset of data for example – Cae.rich Mar 31 '21 at 13:16