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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.