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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3 replies
  • 492 views
  • 3 likes
  • 3 in conversation