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

I would like to find siteid in the site_affected. If it's in the list then I can do something afterward. However, I was not able to use the find, index function to achieve this.

 

I have tried

 

if index(site_affected, siteid) gt 0 then do;

date = 01/JAN/1990;

date2 = 02/JAN/2990;

end;

 

siteid               site_affected

1071                1059; 1061; 1100; 1105; 1190; 1003; 1017; 1022; 1063; 1071; 1144

 

date and dates are empty from the code.

Will appreciate any input!

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Assuming that both variables are character, you should be able to make a small change:

 

if index(site_affected, strip(siteid)) gt 0 then do;

 

That will remove extra blanks that might be part of SITEID, making the longer-version-with-blanks appear is though it as not part of SITE_AFFECTED.

 

There are other possibilities using FINDW, but based on what you posted it looks like this simpler version should be fine.

View solution in original post

2 REPLIES 2
Astounding
PROC Star

Assuming that both variables are character, you should be able to make a small change:

 

if index(site_affected, strip(siteid)) gt 0 then do;

 

That will remove extra blanks that might be part of SITEID, making the longer-version-with-blanks appear is though it as not part of SITE_AFFECTED.

 

There are other possibilities using FINDW, but based on what you posted it looks like this simpler version should be fine.

leela214
Calcite | Level 5
Thank you so much! It work. I tried using the option, 't' -trim in other function too, but didn't work too. I'm glad you were able to solve my question!

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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