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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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