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

I am using enterprise guide 8.2 and SAS 9.4  

%MACRO cycle (name, mo);

 

proc sql;      

create     table &mo AS

select a.creditaccountid, b.statusreasoncode as src_&name, c.externalstatuscode as esc_&name

from newdw.factfinancialmonthly a left join newdw.dimstatusreason b ON a.dimstatusreasonid=b.dimstatusreasonid

left join newdw.dimexternalstatus c ON a.dimexternalstatusID=c.dimexternalstatusID

where reportingdate eq "&mo"d

and activeaccountindicator= 1;

QUIT;

 

%MEND;

%cycle ('jan22','31jan2022'd);

 

ERROR MESSAGE

'31jan2022'd

ERROR22-322: Syntax error, expecting one of the following: a name, a quoted string.  ERROR 200-322: The symbol is not recognized and will be ignored.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

The macro variable reference obviously did resolve.  If it did not resolve then you would have seen &mo in the error message instead of the value of MO.

 

What is it you are trying to do?
What is the SAS code you are trying to use the macro to generate?

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

When you run a macro, all macro variables are replaced by their value. So your macro actually runs this code that I am showing you. This code must be legal valid working SAS code, and it is not.

 

proc sql;      

create     table '31jan2022'd AS

select a.creditaccountid, b.statusreasoncode as src_'jan22', c.externalstatuscode as esc_'jan22'

from newdw.factfinancialmonthly a left join newdw.dimstatusreason b ON a.dimstatusreasonid=b.dimstatusreasonid

left join newdw.dimexternalstatus c ON a.dimexternalstatusID=c.dimexternalstatusID

where reportingdate eq "'31jan2022'd"d

and activeaccountindicator= 1;

QUIT;

Can you see what the problem is here? What different parts of this code are not legal valid working SAS code? How would you fix it to make it legal valid working SAS code?

--
Paige Miller
Tom
Super User Tom
Super User

The macro variable reference obviously did resolve.  If it did not resolve then you would have seen &mo in the error message instead of the value of MO.

 

What is it you are trying to do?
What is the SAS code you are trying to use the macro to generate?

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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