BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
CarolBarahona
Fluorite | Level 6

Hi all! 

 

I have a confussion to perform GLM with a macro. 

I have this: 

 

AB1B2B3B4
0.10211
0.91102
0.782111
0.640200

 

 

and I need to perform several regression over variable the A. For example: A ~B1, A~B2, A~B3 etc.... (I have ~300 of variables). 

Later, I need all the p-values of each association to evaluate if one of the associations is true. 

 

But I don't have clue how to do it... 

 

I really appreciate your help, as always!

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

I think you need to add a CLASS statement to your PROC GLM, since your variable named value is CLASS and not continuous.

 

If you want the overall p-value for the model, you also need the ODS OUTPUT statement like this:

 

ods output overallanova=pe;
proc glm data=try1 noprint;
by VarName;
class value;
model south_ref = Value;
quit;

 

 

--
Paige Miller

View solution in original post

9 REPLIES 9
PaigeMiller
Diamond | Level 26

All explained here: https://blogs.sas.com/content/iml/2017/02/13/run-1000-regressions.html

 

No macros needed.

 

Also, in my opinion, not a good idea to perform regressions like this, hundreds or thousands of variables individually.

--
Paige Miller
CarolBarahona
Fluorite | Level 6

Maybe, I didn't explain very well, but my variable X is categorical (just 3 values are possible) and Y variable is continuous.
So, I think is not possible to perform that code, or am I wrong?

PaigeMiller
Diamond | Level 26

Use PROC GLM instead of PROC REG.

--
Paige Miller
CarolBarahona
Fluorite | Level 6
Yes, but I don't know how to modify the previous code that you send me... sorry! I tried to applied to my dataset and I don't have results...
PaigeMiller
Diamond | Level 26

Show us the code you tried.

--
Paige Miller
CarolBarahona
Fluorite | Level 6

I'm trying with something simple like this:

proc glm data=exp;
class b1;
model a=b1;
run;

but I need to incorporate a macro because I have B1-B300 and also modified to retain just the p-values for each association.

PaigeMiller
Diamond | Level 26

You don't need a macro. The link I gave explains how to do this without a macro. Scroll down to the section entitled "The BY way for many models". Give that a try. If you get stuck, show us your code.

--
Paige Miller
CarolBarahona
Fluorite | Level 6

I modified the code but the problem now, is that the code don't give the p-value for each association evaluated. What is coded as "value" in proc print is not p-value of the association. 

 

data try1;
set exp; /* <== specify data set name HERE */
array new_SNP [*] new_SNP1 - new_SNP280; /* <== specify explanatory variables HERE */
do varNum = 1 to dim(new_SNP);
VarName = vname(new_SNP[varNum]); /* variable name in char var */
Value = new_SNP[varNum]; /* value for each variable for each obs */
output;
end;
drop new_SNP:;
run;

 

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

 

/* 3. Call PROC REG and use BY statement to compute all regressions */
proc glm data=try1 noprint outest=PE;
by VarName;
model south_ref = Value;
quit;

/* Look at the results */
proc print data=PE(obs=5);
var VarName Intercept Value;
run;

PaigeMiller
Diamond | Level 26

I think you need to add a CLASS statement to your PROC GLM, since your variable named value is CLASS and not continuous.

 

If you want the overall p-value for the model, you also need the ODS OUTPUT statement like this:

 

ods output overallanova=pe;
proc glm data=try1 noprint;
by VarName;
class value;
model south_ref = Value;
quit;

 

 

--
Paige Miller

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