Help using Base SAS procedures

deleting when a variable is

Reply
Frequent Contributor
Posts: 102

deleting when a variable is

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??

Trusted Advisor
Posts: 1,228

Re: deleting when a variable is

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;

Super User
Posts: 11,343

Re: deleting when a variable is

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.

Valued Guide
Posts: 2,177

Re: deleting when a variable is

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 ;

Ask a Question
Discussion stats
  • 3 replies
  • 198 views
  • 0 likes
  • 4 in conversation