BookmarkSubscribeRSS Feed
Bal23
Lapis Lazuli | Level 10

 if  substr(icd, 1,3) in ( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9') then num ="Y";else num ="N";

my code does not work

 

any ideas on how to modify?

Thanks

4 REPLIES 4
GreggB
Pyrite | Level 9

Have you run PROC CONTENTS?  

Quentin
Super User

I haven't used it, but perhaps NOTDIGT() is a possibility:

 

184  data _null_;
185    input text $;
186    if notdigit(trim(text))=0 then num="Y";
187    else num="N";
188    put (text num)(=);
189    cards;

text=hello num=N
text=123 num=Y
text=1 num=Y
text=4,321 num=N
text=1.5 num=N
text=m1m num=N

196  ;
197  run;

 

 

I think that should work, nof by numeric you mean contains only numbers.  As shown above, characters such as comma or decimal point are considered non-numeric.

 

Kind Regards,

--Q.

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
Astounding
PROC Star

Clearly, this code will rarely work.  It examines the first three characters in your variable to specifically see if the first character is a digit and the second and third characters are both blanks.  I doubt that is what you wanted to accomplish.

 

What did you want to accomplish?  You will have to explain it in words, rather than show code that doesn't work.

Bal23
Lapis Lazuli | Level 10

you are right, i found this problem and fixed it thanks

sas-innovate-2024.png

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.

 

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