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

Hi All,

I am an amateur and have no idear about macro if it's required in this case. 

It requires me to proceed same analysis on the other 599 variables in the same way as var1 (var1-var600):

proc glm data = training;
class flag;
model var1.=bad_flag;
run;

 

I tried to settle the task in this way:


proc glm data = training;
class flag;
do i=1 to 600;
model var&i.=flag;
run;

 

Warnings said

 apparent symbolic reference I not resolved. 

 variable var not fund.

 

How can I solve it? Pls enlighten me and thank you indeed!

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@aegeangu wrote:

Hi All,

I am an amateur and have no idear about macro if it's required in this case. 

It requires me to proceed same analysis on the other 599 variables in the same way as var1 (var1-var600):

proc glm data = training;
class flag;
model var1.=bad_flag;
run;

 

I tried to settle the task in this way:


proc glm data = training;
class flag;
do i=1 to 600;
model var&i.=flag;
run;

 

Warnings said

 apparent symbolic reference I not resolved. 

 variable var not fund.

 

How can I solve it? Pls enlighten me and thank you indeed!


 

You don't need a macro.

 

 

Try this:

proc glm data = training;
    class bad_flag;
    model var1-var600=bad_flag;
run;

A couple of other points:

 

  • Macros should not be the first choice to do analyses on many variables. Many SAS PROCs are set up so you can easily perform the analysis on lots of variables, as shown in my code. You would only need macros if you were doing something that could need be produced by the proper SAS PROCs, or if you need to make the program dynamic (e.g. if the result of some calculation determines which of multiple paths to follow next)
  • Using PROC GLM this way seems like a waste of time to me, as what are you going to do with the 600 analyses once PROC GLM finishes printing them? Better you should consider the appropriate multivariate statistical method here (for example, MANOVA) 
--
Paige Miller

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

@aegeangu wrote:

Hi All,

I am an amateur and have no idear about macro if it's required in this case. 

It requires me to proceed same analysis on the other 599 variables in the same way as var1 (var1-var600):

proc glm data = training;
class flag;
model var1.=bad_flag;
run;

 

I tried to settle the task in this way:


proc glm data = training;
class flag;
do i=1 to 600;
model var&i.=flag;
run;

 

Warnings said

 apparent symbolic reference I not resolved. 

 variable var not fund.

 

How can I solve it? Pls enlighten me and thank you indeed!


 

You don't need a macro.

 

 

Try this:

proc glm data = training;
    class bad_flag;
    model var1-var600=bad_flag;
run;

A couple of other points:

 

  • Macros should not be the first choice to do analyses on many variables. Many SAS PROCs are set up so you can easily perform the analysis on lots of variables, as shown in my code. You would only need macros if you were doing something that could need be produced by the proper SAS PROCs, or if you need to make the program dynamic (e.g. if the result of some calculation determines which of multiple paths to follow next)
  • Using PROC GLM this way seems like a waste of time to me, as what are you going to do with the 600 analyses once PROC GLM finishes printing them? Better you should consider the appropriate multivariate statistical method here (for example, MANOVA) 
--
Paige Miller
aegeangu
Calcite | Level 5

Thank you very much! 

MANOVA is strange to me not sure whether it requires the vars obey normal distribution... I will work on it. Thank you again!

Reeza
Super User

Transpose your DATA and use BY processing.

 

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

 


@aegeangu wrote:

Hi All,

I am an amateur and have no idear about macro if it's required in this case. 

It requires me to proceed same analysis on the other 599 variables in the same way as var1 (var1-var600):

proc glm data = training;
class flag;
model var1.=bad_flag;
run;

 

I tried to settle the task in this way:


proc glm data = training;
class flag;
do i=1 to 600;
model var&i.=flag;
run;

 

Warnings said

 apparent symbolic reference I not resolved. 

 variable var not fund.

 

How can I solve it? Pls enlighten me and thank you indeed!


 

PaigeMiller
Diamond | Level 26

@Reeza wrote:

Transpose your DATA and use BY processing.

 

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

 


 

That's for hundreds/thousands of X variables. It's completely unnecessary for hundreds/thousands of Y variables.

--
Paige Miller

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 791 views
  • 4 likes
  • 3 in conversation