BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Dhana18
Obsidian | Level 7

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
data have;
input date ;
want=input(put(date,best. -l),yymmdd10.);
format want yymmdds10.;
cards;
20190321
20190216
20190516
;
run;

View solution in original post

7 REPLIES 7
novinosrin
Tourmaline | Level 20

Use format yymmdds10.;

 

format visit_date yymmdds10.;
novinosrin
Tourmaline | Level 20

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;
Dhana18
Obsidian | Level 7
Thank you for replying my request, it did not work for me.
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

SAS date formats is how you take care of that.  Here is a link to those formats.

http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#p1wj0wt2ebe2a0n1lv4l...

self-service is always welcome

 

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

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;
Dhana18
Obsidian | Level 7
It did not work. Log says this.

179 DATA NONSTDEM.PPWI_March_2019_B;
180 SET NONSTDEM.PPWI_March_2019_A;
181 format visdate_newview yymmdds10.;
182 run;

NOTE: Variable visdate_newview is uninitialized.
NOTE: There were 38 observations read from the data set NONSTDEM.PPWI_MARCH_2019_A.
NOTE: The data set NONSTDEM.PPWI_MARCH_2019_B has 38 observations and 31 variables.
NOTE: DATA statement used (Total process time):
real time 1.41 seconds
cpu time 0.03 seconds

and the result is visit_dat_newview is . (blank)
Ksharp
Super User
data have;
input date ;
want=input(put(date,best. -l),yymmdd10.);
format want yymmdds10.;
cards;
20190321
20190216
20190516
;
run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1850 views
  • 0 likes
  • 4 in conversation