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

Hi

I try to find results that correspond to the rule: The character is on the 11th place and is followed by 7 digits, ex. 1234567891A1234567

Could you help me please?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Simple, "brute force" approach:

data have;
input string $20.;
datalines;
1234567891A1234567
XXXXXXXXXXX9999999
1234567891A95X1234
;

data want;
set have;
if substr(string,11,1) = "A" and notdigit(substr(string,12,7)) = 0;
run;

View solution in original post

4 REPLIES 4
J_J_J
Obsidian | Level 7

11th position is fixed and I search for specific character, it's always A, but numbers can vary.

Kurt_Bremser
Super User

Simple, "brute force" approach:

data have;
input string $20.;
datalines;
1234567891A1234567
XXXXXXXXXXX9999999
1234567891A95X1234
;

data want;
set have;
if substr(string,11,1) = "A" and notdigit(substr(string,12,7)) = 0;
run;
J_J_J
Obsidian | Level 7

Thank you so much, Kurt_Bremser!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 852 views
  • 1 like
  • 2 in conversation