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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.