data dup;
input id city$;
cards;
1 hyd
2 blg
2 chn
3 hyd
3 gurg
4 mumb
;
run;
%let Req_id=4;
proc print data=dup noobs;
where id='&Req_id';
run;
Here I have sample table then i defined macro variable Req_id; to get required id
but above code shows error
Two issues:
@BrahmanandaRao wrote:
solution please
You have already got it, with a nice explanation. Don't be rude to people trying to help you.
First, get this code to work WITHOUT macro variables. You have not done this. Once you get it to work without macro variables, then it will be easy to get it to work WITH macro variables. If you can't get it to work WITHOUT macro variables, then it will never work WITH macro variables.
The above is the process you ought to follow for any attempt to use macro variables or macros.
Show us working code WITHOUT macro variables.
The macro processor ignores & and % inside of single quotes. So the macro processor ignored this line.
where id='&Req_id';
so you tried to compare the value if ID to ampersand followed by letters Req_id.
Since you defined ID as numeric you want to write a line like this:
where id=4;
So how should you change the line of code to have that text generated by the macro processor?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.