I would lik eto know whaich sas function to use to get all orders ending with 01. Please reply
Thanks
if substr(var,length(var)-1,2)='01';
Please provide some context, for example:
Amir.
it is character data
585452101
571629201
585175701
24968566
579876301
575507505
184126254
184021353
577099102
Thank you. You could try:
data have;
input order_num $10.;
datalines;
585452101
571629201
585175701
24968566
579876301
575507505
184126254
184021353
577099102
;
data want;
set have;
if left(reverse(order_num)) =: '10';
run;
Amir.
Let's suppose the order number is in a character variable named ORDER_NUM. Then in a SAS data step
if reverse(trim(order_num))=:'10';
if substr(var,length(var)-1,2)='01';
data have;
input var $20.;
cards;
585452101
571629201
585175701
24968566
579876301
575507505
184126254
184021353
577099102
;
data want;
set have;
if substr(var,length(var)-1,2)='01';
run;
/*or indentify/flag*/
data want;
set have;
if substr(var,length(var)-1,2)='01' then flag=1;
run;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.