I want to check if there's a certain variable named "ABC" in the input data set. I can realize it using the following data step:
data want;
set have;
dsid=open('have');
check=varnum(dsid,'ABC');
run;
I will check 'check' and use it for further programming. Now I want to realize the same function using a macro. I have tried the following but it didn't work.
%macro test(&input);
data want;
set &input;
dsid=open('&input'); *The problem might be here;
check=varnum(dsid,'ABC');
run;
%mend;
%test(xxxx)
Does anyone offer some help? Thank you so much!
macro variables only result inside double quotes, not single quotes.
Change to double quotes.
You may also want to consider looking at capturing the outputs of proc contents or querying the dictionary table instead. These are especially useful when your data is large.
macro variables only result inside double quotes, not single quotes.
Change to double quotes.
You may also want to consider looking at capturing the outputs of proc contents or querying the dictionary table instead. These are especially useful when your data is large.
Thank you
Use double quotes so your &input will resolve: "&input"
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.