Hi,
I have a sas dataset with 2 variables. I would like to accomplish below. If the value of VAR2 is part of the string in VAR1 FIND needs to be 1, if not 0. How can I do this ? I've been trying out FINDC, CAT, INDEXC but none of these work.
Many thanks !
VAR1 | VAR2 | FIND |
\TEST1\IPN R1\2012\2013\CLEARPATH-COMMANDS.TXT | IPN R1\2012\DOCUMENT | 0 |
\TEST2\IPN R1\2009\DOCUMENTEN\TRIGGERS DATA_ACCES.TXT | IPN R1\2009\DOCUMENT | 1 |
\TEST3\IPN R1\2006\DOCUMENTATION\VIEW SCH_RGL_GPH.SQL | IPN R1\2006\DOCUMENT | 1 |
One slight correction to @JohnHoughton's suggestion. Since you want 0s and 1s, use:
find=find(var1,var2,'t') gt 0;
Art, CEO, AnalystFinder.com
Hi
use find (string , subtring)
If the substring has trailing blanks (which is most likely) then there are two options
1. Use the t modifier i.e find(string,substring,'t');
2. Use trimn on the substring ie find(string,trimn(substring));
(Use trimn rather than trim in case the substring variable is missing, because trim would return a blank)
One slight correction to @JohnHoughton's suggestion. Since you want 0s and 1s, use:
find=find(var1,var2,'t') gt 0;
Art, CEO, AnalystFinder.com
John and Art,
Thank you very much ! The final solution is :
find=find(%str(mapbestandsnaam),%str(trimn(stringyeardoc)),'t') gt 0;
I'm surprised this function won't try to resolve & s which are in the paths that I scan. Why is that ?
As you can see I'm using %str.
There can also be quotes and percentage signs in the paths so I would need to use %nrbquote also I guess.
Rgds
B
How can I get the find function to work using a field that contains a comma separated list of numbers (i.e 610,610,613,614,675,675)?
if we want exact word match not the character match . how can we do using find ?
ex : var1
awesome customer service today nashville Macys nashvillehospitality raineydayhelp Thanks
var 2
awesome
Thanks
day
help
output: it should consider awesome and Thanks only
please suggest
You really ought to start a new thread when asking a new question. However, I think you are looking for the findw function. e.g.:
data have;
informat var1 $200.;
informat var2 $20.;
input var1 & var2;
find=findw(var1,var2,' .,','t');
cards;
awesome customer service today nashville Macys nashvillehospitality raineydayhelp Thanks awesome
awesome customer service today nashville Macys nashvillehospitality raineydayhelp Thanks Thanks
awesome customer service today nashville Macys nashvillehospitality raineydayhelp Thanks day
awesome customer service today nashville Macys nashvillehospitality raineydayhelp Thanks help
;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.