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

how to populate date like this 

DAT                                               from this format to this format

31DEC2019                                           31 DEC 2019

01MAR2020                                          01 MAR 2020

08MAR2020                                          08 MAR 2020

1JUN2020                                             01 JUN 2020

 

With space

 

Thanks in Advance

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Try this

 

data have;
input date :date9.;
format date date9.;
datalines;
31DEC2019 
01MAR2020 
08MAR2020 
01JUN2020 
;

proc format; 
  picture dtfmt (default=12)
    low - high = '%D %3b %Y' (datatype=date)
  ;
run;

data want;
   set have;
   format date dtfmt.;
run;

View solution in original post

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

Supposing your data is a SAS date and not a string, your best bet is probably to create a picture format to display the date as you request.

PeterClemmensen
Tourmaline | Level 20

Try this

 

data have;
input date :date9.;
format date date9.;
datalines;
31DEC2019 
01MAR2020 
08MAR2020 
01JUN2020 
;

proc format; 
  picture dtfmt (default=12)
    low - high = '%D %3b %Y' (datatype=date)
  ;
run;

data want;
   set have;
   format date dtfmt.;
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1084 views
  • 2 likes
  • 3 in conversation