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!
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
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
Thanks!
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.
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.