Determining if 3rd character is a letter or number?

Accepted Solution Solved
Reply
Contributor
Posts: 25
Accepted Solution

Determining if 3rd character is a letter or number?

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!    


Accepted Solutions
Solution
‎10-06-2012 09:40 PM
Respected Advisor
Posts: 3,156

Re: Determining if 3rd character is a letter or number?

Posted in reply to That____Redhead

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


All Replies
Solution
‎10-06-2012 09:40 PM
Respected Advisor
Posts: 3,156

Re: Determining if 3rd character is a letter or number?

Posted in reply to That____Redhead

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

Contributor
Posts: 25

Re: Determining if 3rd character is a letter or number?

Thanks!    

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 156 views
  • 1 like
  • 2 in conversation