I have visit_date that shows like this
20190321
20190216
20190516 this is in numeric best 12 format
I would like it to be like this
2019/03/21
2019/02/16
2019/05/16
i did
data want;
data have;
format visit_date mmddyy10.;
run;
it did not work. Help me please.
data have;
input date ;
want=input(put(date,best. -l),yymmdd10.);
format want yymmdds10.;
cards;
20190321
20190216
20190516
;
run;
Use format yymmdds10.;
format visit_date yymmdds10.;
If those are just numbers, you may need some conversion
data have;
input date;
cards;
20190321
20190216
;
data want;
set have;
cdate=put(date,8. -l);
want_date=input(cdate,yymmdd8.);
format want_date yymmdds10.;
run;
SAS date formats is how you take care of that. Here is a link to those formats.
self-service is always welcome
data have;
input visit_date yymmdd8.;
cards;
20190321
20190216
20190516
;
data want;
set have;
visit_date_newview = visit_date;
format visit_date_newview yymmdds10.;
run;
data have;
input date ;
want=input(put(date,best. -l),yymmdd10.);
format want yymmdds10.;
cards;
20190321
20190216
20190516
;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.