BookmarkSubscribeRSS Feed
dlazer1
Calcite | Level 5

Hi,

 

My data looks like this. I need to figure out how to delete an observation when it contains specific numbers in the variable RES_ACC_RES_FKEY_LIST.

 

Currently in my code I have

if RES_ACC_RES_FKEY_LIST='55' then delete;

but that does not seem to delete any observations.

 

Thank you for your help!

 

3 REPLIES 3
Reeza
Super User

Assuming its the last column in your screenshot, It looks like it's pipe delimited, so you need to have an exact match. From the screenshot shown no records would match 55. 

 

Assuming you're looking for records that have only 55, I suspect it's actually entered as '|55|'. 

Or if you're searching the list that's a different question and you should use INDEX/INDEXW or FIND/FINDW as appropriate.

 

I'm assuming a lot here...the exact code depends on the details.


@dlazer1 wrote:

Hi,

 

My data looks like this. I need to figure out how to delete an observation when it contains specific numbers in the variable RES_ACC_RES_FKEY_LIST.

 

Currently in my code I have

if RES_ACC_RES_FKEY_LIST='55' then delete;

but that does not seem to delete any observations.

 

Thank you for your help!

 


 

 

 

 

PaigeMiller
Diamond | Level 26

Some of us won't open Microsoft Office documents, as they can be a security risk. You could show us part of your data as plain text in the actual message.

 

Anyway, as a guess, not seeing your data, if this doesn't work for you,

if RES_ACC_RES_FKEY_LIST='55' then delete;

then perhaps you might want to try

 

if find(res_acc_res_fkey_list,'55')>0 then delete;

 

--
Paige Miller
ballardw
Super User

Best is to start by providing an example of your data set. A picture or a table in a word document is not a SAS data set.

 

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 855 views
  • 0 likes
  • 4 in conversation