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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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