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

Hi 

 

I would like to check a field whether all the bytes are having same values.

Eg. I need to check  field EMP_ID which is 9bytes

IF EMP_ID in ('111111111','222222222','333333333',...,'999999999') then 

message = 'invalid employee id';

 

how to replicate the above scenario in an optimal way.

 

Thanks in advance 

1 ACCEPTED SOLUTION
3 REPLIES 3
elangooff1
Calcite | Level 5

Thanks 🙂 this works perfectly

Patrick
Opal | Level 21

@elangooff1

You'll probably need some extra treatment for missing source strings.

 

Here some additional coding options.

data sample;
  infile datalines truncover;
  input instr $char16.;
  flg1 =prxmatch('/^(\d)\1*$/o',strip(instr));
  flg2 =prxmatch('/^(\d)\1*$/o',compress(instr));
  flg3 = compress(instr,substr(instr,1,1)) eq " ";
  datalines;
11111111
2222
11111121
333 333
  444 444
  
 555 6 55
 777 7 77
aaaaaaa
;
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
  • 3 replies
  • 643 views
  • 1 like
  • 3 in conversation