BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Abhi301812
Calcite | Level 5

I want to delete values/rows which are appended with "_U" in the end.

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20
data have;
string="SomeString_U";output;
string="SomeString";output;
string="Some_UString";output;
run;

data want;
	set have;
	where substrn(string,max(1,length(string)-1),2) ne "_U";
run;

View solution in original post

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20
data have;
string="SomeString_U";output;
string="SomeString";output;
string="Some_UString";output;
run;

data want;
	set have;
	where substrn(string,max(1,length(string)-1),2) ne "_U";
run;
Abhi301812
Calcite | Level 5
Thanks, this was helpful
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Or for succinctness:

data have;
string="SomeString_U";output;
string="SomeString";output;
string="Some_UString";output;
run;

data want;
  set have;
  where index(string,"_U");
run;

As a tip @PeterClemmensen, could you use spaces rather than tabs to indent, as tabs get shown differently in different editors Smiley Happy

BrunoMueller
SAS Super FREQ
Please provide some sample data in the form of a DATA Step

See this post on how to convert your SAS data set into a DATA Step program that creates this data
https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1139 views
  • 0 likes
  • 4 in conversation