BookmarkSubscribeRSS Feed
aarony
Obsidian | Level 7

apologies for the hassle I have just two simple questions.

  1. 1)  I want to delete siccd that is equal to 131, 170, 195, 204..and its not working.

data r8; set r7; if siccd in (131,170, 195, 204); run;

  1. 2) I want to delete siccd from 2100-2199

data r8; set r7; if siccd ne (2100-2199); run;


could u plz help??

3 REPLIES 3
stat_sas
Ammonite | Level 13

data r8;

set r7;

if siccd in (131,170, 195, 204) then delete;

run;

data r8;

set r7;

if sicced in (2100:2199) then delete;

run;

ballardw
Super User

data r8; set r7; if siccd in (131,170, 195, 204); run;

As written says to KEEP records only with that value.

To delete RECORDS with that value

data r8; set r7; if siccd in (131,170, 195, 204) then delete; run;

I am not sure if you want to delete records with the values you are giving or if you want to set the value to missing (no value for the variable)

It is usually a good idea to post a few rows of data, some with the values of interes and some without, and what the desired outcome should look like.

Peter_C
Rhodochrosite | Level 12

From your post   you want to delete rows with those values in siccd.

OK just insert the word NOT  into your code before the IN(

Data r8; set r7; if siccd NOT in (131,170, 195, 204); run;

The other is a range not an IN( list    so that is a subsetting IF condition like

if 2100 LE siccd LE 2199 then delete ;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1526 views
  • 0 likes
  • 4 in conversation