BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Reader587
Calcite | Level 5

How do I change the dates 

9/2001

11/2000

1/2011

 to 

9/15/2001

11/15/2000

1/15/2011 ?

There are many more dates in format mm/yyyy and I want to change them to mm/15/yyyy. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star
data _null_;
  month_string = '9/2001';
  SAS_Date = mdy(input(scan(month_string,1),2.),15,input(scan(month_string,2),4.));
  format SAS_Date mmddyys10.;
  put _all_;
run;

View solution in original post

3 REPLIES 3
SASKiwi
PROC Star
data _null_;
  month_string = '9/2001';
  SAS_Date = mdy(input(scan(month_string,1),2.),15,input(scan(month_string,2),4.));
  format SAS_Date mmddyys10.;
  put _all_;
run;
Reader587
Calcite | Level 5

Thank You.

Tom
Super User Tom
Super User

Just prefix the string with 15/ and use the DDMMYY informat.

data have;
  input string $10.;
cards;
9/2001
11/2000
1/2011
;

data want;
  set have;
  date=input(cats('15/',string),ddmmyy10.);
  format date yymmdd10.;
run;

proc print;
run;
Obs    string           date

 1     9/2001     2001-09-15
 2     11/2000    2000-11-15
 3     1/2011     2011-01-15

PS Display dates in DMY or MDY order will confuse 50% of your audience. Use YMD order or the DATE format.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 3 replies
  • 517 views
  • 3 likes
  • 3 in conversation