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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 4 replies
  • 765 views
  • 4 likes
  • 3 in conversation