DATA Step, Macro, Functions and more

need to run this regression repeatedly from a dataset that contains 600 variables (var1....var600)

Reply
Contributor
Posts: 36

need to run this regression repeatedly from a dataset that contains 600 variables (var1....var600)

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

Respected Advisor
Posts: 3,777

Re: need to run this regression repeatedly from a dataset that contains 600 variables (var1....var60

[ Edited ]

Transpose the 600 variable to observations with and BY variable that IDs them.  Then run your program with BY statement.

Contributor
Posts: 36

Re: need to run this regression repeatedly from a dataset that contains 600 variables (var1....var60

thanks for the quick reply

not sure if I understand fully and I have attached the screen shots of dataset and the transposed screenshot.

 

can u be more specific how to plug variable names into this regression model?

 

proc glm data=transposed;

model bodyweight= drug var1 drug*var1

run;


transposed.pngdataset.png
Respected Advisor
Posts: 3,777

Re: need to run this regression repeatedly from a dataset that contains 600 variables (var1....var60

Don't show screen shots.  Include example data in your post that can me copied and pasted into a program.

 

Contributor
Posts: 36

Re: need to run this regression repeatedly from a dataset that contains 600 variables (var1....var60

thanks again.

the dataset (call it dataset1) looks like this

  var1 var2 var3
patient1 10 1 1000
patient2 0 2 1400
patient3 30 3 1300
patient4 40 4

1600

 

 

after transposing it (call it dataset2), it looks like this and I added varname as the header

varname patient1 patient2 patient3 patient4
var1 10 0 30 40
var2 1 2 3 4
var3 1000 1400 1300 1600

 

 

How do I plug the variables (var1....var3) into the regression model?

thanks

 

Respected Advisor
Posts: 3,777

Re: need to run this regression repeatedly from a dataset that contains 600 variables (var1....var60

Run this example and study how it works.

 

proc transpose data=sashelp.class out=class;
   by name age sex;
   var height weight;
   run;
proc sort data=class;
   by _name_;
   run;
proc print;
   run;
proc glm;
   by _name_;
   class sex;
   model age= sex sex*col1;
   run;
Ask a Question
Discussion stats
  • 5 replies
  • 115 views
  • 0 likes
  • 2 in conversation