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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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