%let A ='India','USA','UK','AUSTRALIA';
how to using macro variable A in proc sql
proc sql;
select *
from mytable
where country in(&A)
@pavank wrote:
from mytable means i donot have any table just i have macro variable A only
And what do you want to with that variable?
The where statement is the place a variable defined like A is used. (quoted strings, comma between values).
For what purpose do you want to use the contents of the macro variable (filtering, as part of a string, ...)?
@pavank wrote:
%let A ='India','USA','UK','AUSTRALIA';
how to using macro variable A in proc sql
As in your last thread, we need you to explain a lot more about what you want. No one understands what you want, and by making your explanation one partial sentence, you are not helping yourself or us. To better help us help you, please EXPLAIN the entire problem with sufficient detail taht we know exactly what you want.
how to pass list values in proc sql
%let A ='India', 'USA', 'UK', 'AUSTRALIA' ;
@pavank wrote:
how to pass list values in proc sql
%let A ='India', 'USA', 'UK', 'AUSTRALIA' ;
to achieve what outcome from PROC SQL???
Please, @pavank , show us the code you want without macro variables, in other words show us the code you want with 'India','USA', etc. hard-coded, and then it should be easy to take that code and make use of &A.
@pavank wrote:
how to pass list values in proc sql
%let A ='India', 'USA', 'UK', 'AUSTRALIA' ;
Where do you want to PASS it to?
Let's forget about SQL for now and just work with normal SAS code.
Do you want store that string in a variable? Add double quotes around it.
data want;
mylist= "&a";
run;
Do you want to store each quoted word as a value of a variable in a separate observation?
data want;
length country $20;
do country=&a ;
output;
end;
run;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.