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?
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;
Are the positions fixed?
Do you want to search for specific characters/numbers, or just for the pattern?
11th position is fixed and I search for specific character, it's always A, but numbers can vary.
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;
Thank you so much, Kurt_Bremser!
Nearly 200 sessions are now available on demand in the Innovate Hub.
Watch Now →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.