Hello fellow SAS programmers,
I have this code that I cannot determine how to get beyond the error. The error is "Expecting an arithmetic operator." But, I simply want to do a length of a macro variable value
%let stat=%substr(N PCT N_ANY PCT_ANY,1);
data bob2;
set bob;
do i=1 to length(&stat);
%let st=upcase(scan("&stat",i));
if &st = N then %let _n=Y;
if &st = PCT then %let _pct=Y;
if &st = PERCENT then %let _pct=Y;
if &st = N_ANY then %let _nany=Y;
if &st = PCT_ANY then %let _pctany=Y;
if &_nany=Y or &_pctany=Y then %let _anyev=Y;
end;
run;
NOTE: Line generated by the macro variable "STAT".
1 N PCT N_ANY PCT_ANY
___
388
76
ERROR 388-185: Expecting an arithmetic operator.
ERROR 76-322: Syntax error, statement will be ignored.
If I use %length, I get notes such as the following:
NOTE: Variable N is uninitialized.
NOTE: Variable PCT is uninitialized.
NOTE: Variable PERCENT is uninitialized.
NOTE: Variable N_ANY is uninitialized.
NOTE: Variable PCT_ANY is uninitialized.
NOTE: Variable Y is uninitialized.
I do not even have a variable Y.
My question is: how do I avoid the error and the notes?
If I keep it length(), I do not know how to avoid the error (expecting an arithmetic operator).
If I keep the %length, I do not know how to avoid the notes.
Thank you in advance for your support and for reading my question.
... View more