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;
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!
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.