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

Hey all,

I can't seem to find a quick way of doing this.  I have a string variable, and if the 3rd character is a number, it is indicative of a business, if it is a letter it is an individual.  What is the easiest way to determine this?

I have tried marker = (substr(var,3,1) IN(0:9)); but then when it's text, it gives errors.

Thanks!    

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

Try this:

data have;

input string$ @@;

cards;

adsflk ad2eif ad0euh

;

data want;

set have;

Digiornot=anydigit(substr(string,3,1));

put '1-Digit 0-None Digit' digiornot=;

run;

Haikuo

View solution in original post

2 REPLIES 2
Haikuo
Onyx | Level 15

Try this:

data have;

input string$ @@;

cards;

adsflk ad2eif ad0euh

;

data want;

set have;

Digiornot=anydigit(substr(string,3,1));

put '1-Digit 0-None Digit' digiornot=;

run;

Haikuo

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 610 views
  • 1 like
  • 2 in conversation