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


Hi Team,

I have 2 sas files Prog1.sas prog2.sas like below. while executing prog1.sas in EG it's running fine, but in autosys it's throwing an error.

 

Prog1 code:

options nosyntaxcheck validvarname=any;
%macro DEL_MASTER(NAME);
%if %sysfunc(exist(&name)) %then %do ;

proc datasets library=work memtype=data kill nolist;

quit ;
%end ;
%else;
%put "Data set &name. does not exist";
%mend ;

%DEL_MASTER(piv.*);
options symbolgen mlogic mprint;

%macro post_sql;

%let rundate=01JAN97;
data _null_;
call symputx('rdatem','"'!!put("&rundate."d,date7.)!!'"d');
call symputx('rdate3',"'"!!put("&rundate."d,date9.)!!"'d",'G');
call symputx('rdate',"'"!!put("&rundate."d,date7.)!!"'");
call symputx('date',intnx('day',input("&rundate",date7.),-0));
run;

%global Month_ind;

PROC SQL;
SELECT distinct state into:state_ind
FROM SASHELP.PRDSAL3 t1
WHERE t1.DATE = &rdate3 and state='California';
QUIT;

%include "I:\PIV\Prog2.sas";

%DEL_MASTER(piv.*);

%mend;
%post_sql;


Prog2.sas Code:

%macro Monthly_Scenario;
%if &state_ind=California %then %do;
%put success;
%end;
%mend;
%Monthly_Scenario;
%put &state_ind;


But I am getting an error like below while running in batch mode from autosys.

Error in Log:

ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: 
&state_ind=California
ERROR: The macro MONTHLY_SCENARIO will stop executing.
MLOGIC(MONTHLY_SCENARIO): Ending execution.
MPRINT(POST_SQL): ;
NOTE: The SAS System stopped processing this step because of errors.


Just wanted to understand what is the reason behind it. I am using the nosyntaxcheck options as well. 

 

Please help.

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
3 REPLIES 3
Kurt_Bremser
Super User

To make sure that the macro processor does not try (depending on the contents of your macro variable) to use integer arithmetic, do this:

%if "&state_ind"="California" %then %do;
Tom
Super User Tom
Super User

The first macro in the first program looks like gibberish.  But you seem to be asking about the second program.

 

That is an easy issue.  The state abbreviation OR for Oregon looks to the macro processor like the logical operator or.  You can test it easily.

%put %eval( OR=California );

To prevent the implied %EVAL() call in the %IF statement from treating your macro variable value as an operator you could use macro quoting.  But it is probably a lot easier to just add quotes around the values being compared.

%if "&state_ind"="California" %then %do;

 

rajdeep
Pyrite | Level 9
Thanks a lot Tom. That worked. Next time onwards will keep this in mind.

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
  • 3 replies
  • 664 views
  • 1 like
  • 3 in conversation