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

Hi!

 

I have a variable: Report_Num

 

Character values should be xx-xxx (e.g 07-041)  BUT some values have an extra character at the end (eg. 07-055D).

Is there a way to strip off that last character for some of these values?

 

Thanks!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Is there a rule we can use to identify the errant value? Does the character value actually contain ")" or were you just setting that off as example? 

 

Maybe a rule such as the character at the end must be a numeral or in some other list of characters?

Or the overall lenght of the variable has a specific length. The length of 07-055D would be 7 so you might use in a data step

 

Value = substr(value,1,6); which would strip of anything past the sixth character.

View solution in original post

2 REPLIES 2
ballardw
Super User

Is there a rule we can use to identify the errant value? Does the character value actually contain ")" or were you just setting that off as example? 

 

Maybe a rule such as the character at the end must be a numeral or in some other list of characters?

Or the overall lenght of the variable has a specific length. The length of 07-055D would be 7 so you might use in a data step

 

Value = substr(value,1,6); which would strip of anything past the sixth character.

Reeza
Super User

Is it always xx-XXX? If so, could you substring out that portion and 'leave behind' the character?

 

my_char = substr(old_char, 1, 6);

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
  • 2 replies
  • 4295 views
  • 2 likes
  • 3 in conversation