BookmarkSubscribeRSS Feed
mh2t
Obsidian | Level 7

How can I get an output from PROC GLM to be like below:

 

VarName   RSQUARE   height_MEAN   Coeff Var
    weight           xx                xxx                   ww
      sex              yy                yyy                   www

 

It is easy in proc reg but I don't know how to do it in proc glm.

Thank you for your response. 

7 REPLIES 7
Reeza
Super User
You have an RSquare for each variable? How does that work?
mh2t
Obsidian | Level 7
so we run two univariate glm models, each has a separate RSquare in the output.
Reeza
Super User
Do you have code to already run all those regressions? If we can add our solution to yours that's more efficient.
mh2t
Obsidian | Level 7
/* 1. transpose from wide (Y, X1 ,...,X100) to long (varNum VarName Y Value) */
data Long;
set Wide;                       /* <== specify data set name HERE         */
array x [*] x1-x&nCont;         /* <== specify explanatory variables HERE */
do varNum = 1 to dim(x);
   VarName = vname(x[varNum]);  /* variable name in char var */
   Value = x[varNum];           /* value for each variable for each obs */
   output;
end;
drop x:;
run;

/* 2. Sort by BY-group variable */
proc sort data=Long;  by VarName;  run;


/* 3. univariate glm regression on single predictor*/
proc glm data=Long outstat=PE;
   CLASS Value;
   by VarName;
   model Y = Value;
   ods select FitStatistics;
quit;

proc print data=PE;
run;quit;
Reeza
Super User
/* 3. univariate glm regression on single predictor*/
proc glm data=Long outstat=PE;
   CLASS Value;
   by VarName;
   model Y = Value;
   *ods select FitStatistics;
ods output fitstatistics = rSquared parameterEstimates = PE(where=(Parameter='Value'));
quit;

This will capture the data for you in a clean fashion into two data sets rSQuared and PE. You can then merge them to get the table you want. I think for means you'll need a PROC MEANS for mean.

 

mh2t
Obsidian | Level 7
Thank you @Reeza. I'm very new to SAS environment, I don't know how to merge them.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 861 views
  • 0 likes
  • 2 in conversation