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

Hi,

I have a litte macro that reports the agencies that did not complete a submission.

/*get the names of the agencies that did not report*/

sql noprint;

SELECT agency into:missing_agency separated by ' and '

from agency_list;

quit;

SYMBOLGEN:  Macro variable MISSING_agency resolves to agency1 and agency2

/*MACRO TO WRITE THE NAME OF THE NON REPORTERS, IF ANY*/

%macro DidnotReport_AGENCY(missing_agency);

%if &missing_agency = %str() %then %do;

/*%put "Macro Variable is empty";*/

  %end;

  %else %do;

ods region  x=1.0in y=6.5in;

Ods pdf text="^S={font=('Arial' ,10pt, bold ) just=center } Note: %trim(&Missing_agency) did not report this week";

%end;

%mend;

/*RUN THE MACRO*/

%didnotreport_AGENCY(&missing_agency);

ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric

  operand is required. The condition was: &missing_agency =


ERROR: The macro DIDNOTREPORT_agency will stop executing.


So I figured it had something to do with the fact that there are two non reporters (macro works well with only one non-reporting agency)

so I reasigned the missing agency to "peter"

  %let missing_agency = peter;

AND THE LOG SAID:

SYMBOLGEN:  Macro variable MISSING_agency resolves to agency1 and agency2


NOTE: A missing equal sign has been inserted after the variable name agency1.

That's interesting!

Why does this happen? And how can I get the name of two agencies to list in the report?

1 ACCEPTED SOLUTION

Accepted Solutions
jakarman
Barite | Level 11

code it this way:
    %if "&missing_agency " = " " %then %do;
By that your value testing will be string based comparison.   

In you original code the string is put into the macro language. You error message is telling you you have a macro language error.
Think of using SAS macro-s you can modify all kind of strings before it is going (reviewed ) into those nested language interpreters.

---->-- ja karman --<-----

View solution in original post

3 REPLIES 3
jakarman
Barite | Level 11

code it this way:
    %if "&missing_agency " = " " %then %do;
By that your value testing will be string based comparison.   

In you original code the string is put into the macro language. You error message is telling you you have a macro language error.
Think of using SAS macro-s you can modify all kind of strings before it is going (reviewed ) into those nested language interpreters.

---->-- ja karman --<-----
Quentin
Super User

Hi,

The word AND is tripping up the implied %eval() in the %IF statement.  You can add macro quoting:

%if %superq(missing_agency)=%str() ...

Or for a utility macro %IsBlank that does this check for you, see:

http://changchung.com/download/022-2009.pdf


BigD
Calcite | Level 5

Thanks so much..

Bruce

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