Desktop productivity for business analysts and programmers

Why won't a string macro variable compile using %syslput in EG?

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

Why won't a string macro variable compile using %syslput in EG?

I am passing month and dates macro variables using the Parameter (macro variable) Manager in EG to a remote session. &Month is classifed as string while &date1 and &date2 are integers. I then use the following codes:

%syslput rmonth=%bquote(&month);
%syslput rdate1=&date1;
%syslput rdate2=&date2;

rsubmit;
%put &rmonth. &rdate1. &rdate2.;
proc contents data = ASPCCR.Cmsambs&rdate1.&rdate2.;
run;
proc contents data = TRIAD.Base_&rmonth.;
run;
endrsubmit;

And here's the log excerpt. I can see the local macro variables were passed correctly remotely but it will not recognised JUN12 (&rmonth). Can anyone help please? I tried restricting the string length to 5 but still the same error. Also checked that TRIAD.Base_JUN12 exists and the code runs smoothly without macro variables.

SYMBOLGEN:  Macro variable MONTH resolves to JUN12
SYMBOLGEN:  Some characters in the above value which were subject to macro quoting have been unquoted for printing.
17       
18        %syslput rmonth=%bquote(&month);
SYMBOLGEN:  Macro variable DATE1 resolves to 1206
19        %syslput rdate1=&date1;
SYMBOLGEN:  Macro variable DATE2 resolves to 29
20        %syslput rdate2=&date2;
21       
22        rsubmit;
NOTE: Remote submit to CREDIT commencing.
13    %put &rmonth. &rdate1. &rdate2.;
JUN12 1206 29


14    proc contents data = ASPCCR.Cmsambs&rdate1.&rdate2.;
15    run;

NOTE: PROCEDURE CONTENTS used (Total process time):
      real time          0:00.03
      cpu time            0:00.03
     
NOTE: The PROCEDURE CONTENTS printed pages 20-38.

16    proc contents data = TRIAD.Base_&rmonth.;
NOTE: Line generated by the macro variable "RMONTH".
16    TRIAD.Base_JUN12
                  -----
                  22
                    -----
                    202
ERROR: File TRIAD.BASE_.DATA does not exist.
ERROR 22-322: Syntax error, expecting one of the following: ;, (, CENTILES, DATA, DETAILS, DIR, DIRECTORY, FMTLEN, LIB, MEMTYPE,
              MT, MTYPE, NODETAILS, NODS, NOPRINT, ORDER, OUT, OUT2, SHORT, VARNUM. 
ERROR 202-322: The option or parameter is not recognized and will be ignored.
17    run;

NOTE: Statements not processed because of errors noted above.
2                                                          The SAS System                        09:51 Wednesday, November 14, 2012

NOTE: PROCEDURE CONTENTS used (Total process time):
      real time          0:00.00
      cpu time            0:00.02
     
NOTE: The SAS System stopped processing this step because of errors.
NOTE: Remote submit to CREDIT complete.


Accepted Solutions
Solution
‎11-13-2012 11:46 PM
Super User
Super User
Posts: 6,326

Re: Why won't a string macro variable compile using %syslput in EG?

The %BQUOTE() is causing the tokenizer to incorrectly stop before &rmonth value when trying to parse the name of the dataset.

Try doing something to remove the quoting. Such as :

proc contents data = %unquote(TRIAD.Base_&rmonth.) ;


Why are you using %BQUOTE()?  It looks like you want the use the value the macro variable MONTH that is defined in the remote session rather than the value in the local session.  Are they really different? 

View solution in original post


All Replies
Solution
‎11-13-2012 11:46 PM
Super User
Super User
Posts: 6,326

Re: Why won't a string macro variable compile using %syslput in EG?

The %BQUOTE() is causing the tokenizer to incorrectly stop before &rmonth value when trying to parse the name of the dataset.

Try doing something to remove the quoting. Such as :

proc contents data = %unquote(TRIAD.Base_&rmonth.) ;


Why are you using %BQUOTE()?  It looks like you want the use the value the macro variable MONTH that is defined in the remote session rather than the value in the local session.  Are they really different? 

New Contributor
Posts: 4

Re: Why won't a string macro variable compile using %syslput in EG?

Hi Tom,

It had a different error if I don't use %bquote. It's REALLY bizarre but yur suggestion to unquote it works beautifully. Thanks!

21         rsubmit;
NOTE: Remote submit to CREDIT commencing.
21    %put &rmonth. &rdate1. &rdate2.;
JUN12 1206 29
22    /*proc contents data = ASPCCR.Cmsambs&rdate1.&rdate2.;*/
23    /*run;*/
24    proc contents data = TRIAD.Base_&rmonth.;

      -----
      22
      202
ERROR: File TRIAD.BASE_.DATA does not exist.
ERROR 22-322: Syntax error, expecting one of the following: ;, (, CENTILES, DATA, DETAILS, DIR, DIRECTORY, FMTLEN, LIB, MEMTYPE,
              MT, MTYPE, NODETAILS, NODS, NOPRINT, ORDER, OUT, OUT2, SHORT, VARNUM. 
ERROR 202-322: The option or parameter is not recognized and will be ignored.
25    run;

NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE CONTENTS used (Total process time):
      real time           0:00.04
      cpu time            0:00.03

Super Contributor
Posts: 644

Re: Why won't a string macro variable compile using %syslput in EG?

It is odd that the first proc contents worked while the second did not.  I'm guessing ASPCCR is a stock SAS library while TRIAD is a SAS/Access libname.

Why are you using %BQUOTE()? All macro variables are strings, no need to try and "quote" them (which has a different effect in SAS Macro language).

Try

%syslput rmonth=&month;

If for some reason you must use %BQUOTE() then at the rsubmit

rsubmit;

%let rmonth = %unquote(&rmonth);


Richard in Oz

New Contributor
Posts: 4

Re: Why won't a string macro variable compile using %syslput in EG?

Hey Richard,

Yes it doesn't work without the %bquote (see response to Tom above). Your suggestion to unquote works beautifully. Thanks!

Super Contributor
Posts: 644

Re: Why won't a string macro variable compile using %syslput in EG?

Suggests to me that the problem is created further up in your code wherever &month is initially assigned.  JUN12 is a perfectly ordinary string value and it should not need to be wrapped in %BQUOTE().  I would insert the line


%let month = %unquote(&month);

well before the %syslput rmonth= statement to prevent all downstream issues with &month and &rmonth.

Richard in Oz

New Contributor
Posts: 4

Re: Why won't a string macro variable compile using %syslput in EG?

That's exactly what I think also, Richard. The code provided is the complete code - I suspect the EG Parameter Manager does something funny with string macro variables. When I searched online, SAS suggested using %bquote with %syslput in SAS 9.

Super Contributor
Posts: 644

Re: Why won't a string macro variable compile using %syslput in EG?

OK, I forgot this thing had EG wrapped around it.  Anything can happen.  I'll bear it in mind if I ever have to %syslput in EG.

Richard in Oz

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 539 views
  • 3 likes
  • 3 in conversation