BookmarkSubscribeRSS Feed
pavank
Obsidian | Level 7
%let  A ='India','USA','UK','AUSTRALIA';

how to using macro variable A in proc sql

9 REPLIES 9
rudfaden
Pyrite | Level 9
proc sql;
select *
from mytable
where country in(&A)

 

pavank
Obsidian | Level 7
from mytable means i donot have any table just i have macro variable A only
andreas_lds
Jade | Level 19

@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).

rudfaden
Pyrite | Level 9
What are you trying to achive?
PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller
pavank
Obsidian | Level 7

how to pass list values in proc sql 

 

%let A ='India',  'USA',    'UK',    'AUSTRALIA'  ;

PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller
Tom
Super User Tom
Super User

@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;

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

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
  • 9 replies
  • 874 views
  • 0 likes
  • 6 in conversation