Hi All,
I have two sasdatasets , one has column ID which has 8 digit number. The second dataset has a text field in which it has ID from the first dataset any where placed in the text field. I need a column in the second dataset which says "exists" if the ID exists in the first dataset.
Example :
First Dataset : 12345678
Second data set text Value: **Request #12345678-Corporate Membership
In the text field the ID value can be anywhere in the text. Basically for every ID in the first dataset it has to loop through all records in the second dataset and put a flag exists in that row where it matches in the second dataset.
Thanks In Advance,
Vani.
index() function should be able to handle it:
proc sql; create table WANT as select A.*, case when B.VAL is not null then 1 else 0 end from LONGSTRING A left join SMALLDATA B on index(A.VAL,B.VAL)>0; quit;
This should join the small dataset to the larger one, based on finding the small string in the big string.
index() function should be able to handle it:
proc sql; create table WANT as select A.*, case when B.VAL is not null then 1 else 0 end from LONGSTRING A left join SMALLDATA B on index(A.VAL,B.VAL)>0; quit;
This should join the small dataset to the larger one, based on finding the small string in the big string.
Thank you. It did work , got that extra flag column as I want.
Please provide some example data from each data set and the result. The wording you are describing for output has a couple of different interpretations and an example of what the output looks like would help determine which meaning(s) to use. For instance what if the ID is duplicated in the first set. One interpretation would be to create two or more 'marked' result records in the output.
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.