Since you did not post the sample data, so I created it for myself
Creating a sample dataset. Taking phonenumas numericmuch as in your case.
data test;
infile datalines;
input phonenum : 8.;
datalines;
123
1234
12345
123456
1234567
12345678
123456789
12345678910
;
run;
You are right in the approach, if you want to count the number of digits, you need to convert it to charby following these steps:
- Convert
numericphonenum to char. Although it is obvious that the number of digits will not be more than 32, but if you want to increase the score. - Using
compressfor stripempty symbols - Using a function
lengthto count the number of digits proc sql\SAS where , proc sql , calculated .
proc sql;
select length(compress(put(phonenum,32.))) as phonelen from test where calculated phonelen > 6;
quit;
, datasteps (SAS), :
data _null_;
set test;
phonelen=length(compress(input(phonenum,$32.)));
if phonelen > 6;
put phonelen=;
run;