Hi,
I have data set and want to select particular contents from variables and want to update desire value in another variable.
Example-
data test;
input id category
cards;
11BRG234
12IMF456
run;
expecting below result in data
Id Category
11BRG234 Broker
12IMF456 Agent
Please suggest
data want;
set test;
if find(id,'BRG') then category = 'Broker';
run;
You apparently want all observations with the string "BRG" in the id variable:
data want;
set test;
where find(id,'BRG');
run;
which filters through all observations in which the FIND function returns a non-zero value. Since the FIND function returns the character position at which the string 'BRG' appears in the id variable. It returns a zero when the string is not found.
data want;
set test;
if find(id,'BRG') then category = 'Broker';
run;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.