BookmarkSubscribeRSS Feed
rykwong
Quartz | Level 8

Dear all,

I have this logistic regression model and would like to extract the p value of the interaction term "drug*var1".

 

proc glm data=test;

model bodyweight = drug var1 drug*var1;

run;

 

 

Problem is I need to do this 600 times because there are var1, var2, var3.....  .... var600.  Any thoughts appreciated!!

 

Raymond

2 REPLIES 2
Karlb
Calcite | Level 5

Hi,

the idea is as follows

 

with

ODS listing off;

you can stop procedure list output

 

with

ODS output....;

you can direct procedure results (in your case the p values) to datasets, please check exact syntax...

 

finally you macro loop around the Proc glm

 

%macro writep;

%do k=1 %to 600;

ods output ...out=pdset&k;

proc glm;

model bodyw = drug var&k drug * var&k;

run;

%end;

proc append base=pvalues data=pdset&k; run;

%mend;

 

%writep;

 

hope it helps...

sincerly Karl

 

Rick_SAS
SAS Super FREQ

Although Karlb's solution will work, it tends to be slow. An alternative solution is to transform the data from wide form to long form. The new form of the data will contain 600 BY groups. The first contains the data for Y, Drug, and X1.  The second contains the data for Y, Drug, and X2. And so on.   For an example and discussion, see the article

"An easy way to run thousands of regressions in SAS"

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