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

I'm trying to run some proc sql within a macro and SAS won't recognise my macro variables.  What am I doing wrong...

 

%macro sixmonthroll(startdate,longstart,longend);

rsubmit;

proc sql;

create table &startdate. as

etc.

etc.

quit;

endrsubmit;

%sixmonthroll (jan16,jan_2016,jul_2016);

 

When I run the code above I get the following error:

 

224 %sixmonthroll (jan16,jan_2016,jul_2016);

NOTE: Remote submit to HOST commencing.

491 proc sql;

492 create table &startdate. as select

                 -

                 22

                 200

 

WARNING: Apparent symbolic reference STARTDATE not resolved.

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string.

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

@cstanyer wrote:
Could I move the rsubmits from within the macro code and rsubmit the %sixmonthroll instead?

That would only work if you also defined the macro remotely:

rsubmit;
%macro testmac(parameters);
/* statements */
%mend;
%testmac(params);
endrsubmit;

View solution in original post

6 REPLIES 6
cstanyer
Calcite | Level 5

 I wondered if it was something to do with that.  I've not used %syslput before- I'll look into it, thank you.

Kurt_Bremser
Super User

While macro statements like %let or %put or %if...%then...%else are executed locally, macro variable references are transferred to the remote session "as is" and resolved there, so one needs to create the macro variables in the remote session before using them.

cstanyer
Calcite | Level 5
Could I move the rsubmits from within the macro code and rsubmit the %sixmonthroll instead?
Kurt_Bremser
Super User

@cstanyer wrote:
Could I move the rsubmits from within the macro code and rsubmit the %sixmonthroll instead?

That would only work if you also defined the macro remotely:

rsubmit;
%macro testmac(parameters);
/* statements */
%mend;
%testmac(params);
endrsubmit;
cstanyer
Calcite | Level 5

That's what I did.  Thanks for the help!

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