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


BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
BigD
Calcite | Level 5

Thanks so much..

Bruce

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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