01-30-2017 02:16 AM
My dataset consists a variable named as "REPORTING_ENTITY" in the form of string. Now, from that variable i want create a new dataset which consist a observations with keywords as ('Bank','Loan','Cooperative','SBI','Insurance') from "REPORTING_ENTITY" also want that strings get deleted from original dataset. I did something like:
where REPORTING_ENTITY contains ('Bank','Loan','Cooperative','SBI','Insurance');
This will create a new dataset with mentioned keywords but it will not get deleted from orignal dataset..
01-30-2017 02:31 AM
Just to see if I understand correctly, you want a new variable i your new dataset based on the variable REPORTING_ENTITY, where you want the substring eg "Bank" to be deleted from the string such that eg "New York Bank" becomes "New York"?
01-30-2017 02:53 AM
no...... i want "newyork bank" to be seperated whole from existing dataset not only "bank"...plz help me on this...
01-30-2017 02:41 AM
I would do it like that:
data class.sample work.origsample ; set work.sample; if REPORTING_ENTITY contains ('Bank','Loan','Cooperative','SBI','Insurance') then output class.sample; else output work.origsample; run;
Once you have verified that the step ran successfully, you can remove work.sample and rename work.origsample to work.sample.
01-30-2017 04:44 AM - edited 01-30-2017 04:48 AM
I'd run that code but it shows error in log window as:
22-322 Syntax error, expecting one of the following: !, !!, &, (, ), *, **, +, ',', -, '.', /,
<, <=, <>, =, >, >=, ?, AND, EQ, EQT, EXCEPT, GE, GET, GT, GTT,
HAVING, IN, INTERSECT, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, OUTER,
UNION, ^, ^=, |, ||, ~, ~=.
68-185 The function CONTAINS is unknown, or cannot be accessed.......
01-30-2017 09:56 AM
The contains operator can only be used in a datastep's where clause. However, you can accomplish the same thing with a series of statements that use the FIND function. Take a look at: http://support.sas.com/kb/43/303.html
Art, CEO, AnalystFinder.com