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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.