Hi Everyone,
I have a quick question. When I run the
if index(project,"VI SP - OH")>0 then output;
SAS pick up also record such as "014 VI SP" which clearly have no "- OH" component.
Can you fix my code so it strictly pick only those containing "VI SP - OH" ?
Thank you,
HHC
The INDEX function works correctly. Double check your data and the rest of the logic in your program. Are you outputting other records by using another OUTPUT statement?
The INDEX function works correctly. Double check your data and the rest of the logic in your program. Are you outputting other records by using another OUTPUT statement?
Something else is your issue.
The INDEX function will not match strings that are not exactly the same.
574 data test; 575 input project $70. ; 576 found=index(project,"VI SP - OH"); 577 put found= project=$quote. ; 578 cards; found=0 project="014 VI SP which clearly have no ""- OH"" component." found=5 project="015 VI SP - OH" NOTE: The data set WORK.TEST has 2 observations and 2 variables.
My bad. I am sorry.
HHC
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.
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.