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

Let me begin by saying I am just starting to learn how to program.

 

I have a good size dataset with 14017 observations and 375 variables.

There are 10 variables of interest where I want to delete different values (they are characters)

Variables are CONCPT1, CONCPT2, ans so forth until CONCPT10 and values are hundreds of different values (i.e. 32551, 32160, 38746, 21620 and so on).

 

I tried the IF then delete statement with success if I include one value such as:

data pd6; set pd5;

if CONCPT1 = '32551' then delete;

run;

 

However, I want to delete hundreds of values from different variables (CONCPT1 - CONCPT10) and when I try to include more I receive an error (missing an operator or an incorrect answer)

 

I tried including more values to the IF statement but the result is not accurate.  For example:

data pd6; set pd5;

if CONCPT1 = '32551' '32160' '38746' then delete;

run;

 

Please let me know if I can be of any help with more information.

Thanks,

JG

 

1 ACCEPTED SOLUTION

Accepted Solutions
saslove
Quartz | Level 8

You need an "IN" operator with comma in between.

 

data pd6; set pd5;

if CONCPT1 in ( '32551', '32160', '38746') then delete;

run;

View solution in original post

5 REPLIES 5
saslove
Quartz | Level 8

You need an "IN" operator with comma in between.

 

data pd6; set pd5;

if CONCPT1 in ( '32551', '32160', '38746') then delete;

run;

FreelanceReinh
Jade | Level 19

@saslove wrote:

You need an "IN" operator with comma in between.

 

data pd6; set pd5;

if CONCPT1 in ( '32551', '32160', '38746') then delete;

run;


Commas are not required, blanks are sufficient.

Jarot741
Calcite | Level 5

Thank you so much! I will look into it!

SAS Innovate 2025: Call for Content

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 5 replies
  • 3330 views
  • 1 like
  • 4 in conversation