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

 

Hi , wherever the Number(lessthen five count),Characters and Special Character are availabel then that should be return as "0" and only numbers count greaterthen or equal to 5 then that should return as "1 in sas EG.Kindly help.

 

haveLengthwant
12345661
123456771
1234567881
12345678991
110ask-70
_wertn60
gst30
12330
152640
1235651

 

Thanks,

Siva

1 ACCEPTED SOLUTION

Accepted Solutions
gamotte
Rhodochrosite | Level 12

Hello,

 

data have;
	input x $9.;
	drop toNum;

	toNum=input(x, ? 9.);

	if toNum>9999 and strip(put(toNum,9.))=strip(x) then y=1;
	else y=0;

	cards;
123456
1234567
12345678
123456789
110ask-
_wertn
gst
123
1526
12356
;
run;

View solution in original post

6 REPLIES 6
gamotte
Rhodochrosite | Level 12

Hello,

 

data have;
	input x $9.;
	drop toNum;

	toNum=input(x, ? 9.);

	if toNum>9999 and strip(put(toNum,9.))=strip(x) then y=1;
	else y=0;

	cards;
123456
1234567
12345678
123456789
110ask-
_wertn
gst
123
1526
12356
;
run;
sivastat08
Pyrite | Level 9
Thank you Gamotte
Ksharp
Super User

data have;
	input x $9.;
length=length(x);
if length ge 5 and notdigit(strip(x))=0 then flag=1;
 else flag=0;
	cards;
123456
1234567
12345678
123456789
110ask-
_wertn
gst
123
1526
12356
;
run;


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
  • 6 replies
  • 869 views
  • 3 likes
  • 4 in conversation