the data set contains many variable of character and numeric types but i need to print only those number having length equals 12 and it should be numbers.
kindly help.(No macros)
Or the other possibility being eliminate non digit values using compress and filter based on length
data a;
input id $30.;
cards;
123456789012
1234567890qa
123456
asdghjj098752
123456789087654
run;
data want;
set a;
if length(compress(strip(id),,'kd'))=12;
run;
Hi @asuman Can you post a sample along with your description plz
data a;
input id;
cards;
123456789012
1234567890qa
123456
asdghjj098752
123456789087654
run;
need to print only those records having length=12 and it should be numbers only.
Are you after this?
data a;
input id $30.;
cards;
123456789012
1234567890qa
123456
asdghjj098752
123456789087654
run;
data want;
set a;
if notdigit(strip(id))=0 and length(strip(id))=12;
run;
Or the other possibility being eliminate non digit values using compress and filter based on length
data a;
input id $30.;
cards;
123456789012
1234567890qa
123456
asdghjj098752
123456789087654
run;
data want;
set a;
if length(compress(strip(id),,'kd'))=12;
run;
Both solutions works perfectly.
thanks novinosrin.
Regards,
aditya suman
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.