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

Let's say that I want to :


DATA data_name;

SET set_name;

WHERE CLIENTS IN ("SECTOR_1","SECTOR_2","SECTOR_3");

Run;

How can I parameterize ("SECTOR_1","SECTOR_2","SECTOR_3")? 

I would like to sometimes run it just for SECTOR_1 AND SECTOR_2, and sometimes just SECTOR_3, for example.
Is there a way to create a macrovariable with the condition? "CLIENTS IN MACROVARIABLE"


1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Create a macro variable with the list of items you want to select.

 

%let selection = "SECTOR_1", "SECTOR_2";

data want;
set have;

where clients in (&selection.);

run;

But I suspect this isn't actually what you want, so if that's true, you need to provide more details on what you do want.

View solution in original post

3 REPLIES 3
Reeza
Super User

Create a macro variable with the list of items you want to select.

 

%let selection = "SECTOR_1", "SECTOR_2";

data want;
set have;

where clients in (&selection.);

run;

But I suspect this isn't actually what you want, so if that's true, you need to provide more details on what you do want.

victorlu
Calcite | Level 5
that's exaclty what i want !

Obviously i createad a analogous problem, but that should do it!

ballardw
Super User

Are you actually replacing the data set DATA_NAME, or what that  may represent, multiple times? That likely would not be needed as you can use a where statement in many procedures and a data set option where in others.

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 845 views
  • 4 likes
  • 3 in conversation