Hi
I am getting below error when executing below stmnt in a macro . Val is numeric and runstatus is character .
%if (val=0) AND (Runstatus = 'F' or RUNSTATUS='' ) %then
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:
val=1 and runstatus = "F" or ""
Kindly advise.Thanks
The text(!) val is never numeric; either you missed using the ampersand for macro variable &val, or you tried to access a data step variable, which is impossible from the macro preprocessor.
To clarify, post your complete code.
%if construct is a macro function. You cannot use datastep variables in the construct - macro is resolved before datastep compilation.
Post your code on what you are trying to do - we can't tell from tiny snippets. First question would be why you are using a macro if construct to try to check datastep variables which will not work.
You CANNOT access data step variables from macro code, period. Use data step code instead.
There can only be one datastep active at any given time. Please describe what you want to accomplish, post example data (in a data step to easily recreate your data), and what your expected result should look like.
Post examples, show test data in the form of a datastep, and what you want to achieve. Its hard to keep guessing what you mean. You can create code from one datastep in numerous ways:
data _null_; set have; if val=1 then call execute('data want; file "abc.txt";...;run;'); run;
For example.
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.
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.