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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 1249 views
  • 0 likes
  • 4 in conversation