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

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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.

View solution in original post

3 REPLIES 3
Reeza
Super User

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.

PeterPanPan
Calcite | Level 5

Thank youSmiley HappySmiley HappySmiley Happy

SASKiwi
PROC Star

Use double quotes so your &input will resolve: "&input"

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 648 views
  • 3 likes
  • 3 in conversation