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 ;

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!

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.

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
  • 3 replies
  • 759 views
  • 0 likes
  • 4 in conversation