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;
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.