Hello friends,
I am trying to drop observations ending in "_A" of the variable, "category". I used the following code and didn't work. Could you please help?
If substr(category, - 1, 2)="_0" then delete;
Thank you and all have a wonderful weekend!
Rube
You cannot use negative numbers with SUBSTR().
if substrn(category,length(category)-1) = '_A' then delete;
You can use negative numbers with SCAN().
if scan(category,-1,'_') = 'A' then delete;
Do you ever have values that are just 'A' without any underscore?
Do you ever have values with lowercase a as the suffix?
if index(category,'_') and upcase(scan(category,-1,'_')) = 'A' then delete;
You cannot use negative numbers with SUBSTR().
if substrn(category,length(category)-1) = '_A' then delete;
You can use negative numbers with SCAN().
if scan(category,-1,'_') = 'A' then delete;
Do you ever have values that are just 'A' without any underscore?
Do you ever have values with lowercase a as the suffix?
if index(category,'_') and upcase(scan(category,-1,'_')) = 'A' then delete;
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.