To answer your question,
So you want to test whether variable1, (or 2 or 3 or 4) exists in table_name, and run the value check only if it in the data set - is that right? - yes
Could you please help me understand how to pass the Input to the below macro variables? Also I would like to why you've creating macro variable 'i' only till 4. Instead of hard coding can we find the dynmaic way to handle this?
%do i=1 %to 4;
%let variable&i=%upcase(&&variable&i);
%if %sysfunc(findw(&csv_varnames,&&variable&i))=0 %then %let variable&i=%str();
%end;
What I tried is,
%macro validation(variable1,variable2,variable3);
data _null_;
%do i=1 %to 4;
%let variable&i=%upcase(&&variable&i);
%if %sysfunc(findw(&csv_varnames,&&variable&i))=0 %then %let variable&i=%str();
%end;
run;
%mend;
%validation;
Error message is,
SYMBOLGEN: Macro variable I resolves to 4
MLOGIC(VALIDATION): %LET (variable name is VARIABLE4)
SYMBOLGEN: && resolves to &.
SYMBOLGEN: Macro variable I resolves to 4
WARNING: Apparent symbolic reference VARIABLE4 not resolved.
WARNING: Apparent symbolic reference VARIABLE4 not resolved.
ERROR: The text expression &VARIABLE4 contains a recursive reference to the macro variable VARIABLE4. The macro variable will be
assigned the null value.
... View more