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!
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.
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.
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!
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.
Ready to level-up your skills? Choose your own adventure.