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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.