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

Hi,

I have a dataset with dateofbirth

1950-04-13

1920-02-26

1940-03-23

I want to change to

04/13/1950

02/26/1920

03/23/1940

can I do this? Please let me know.

thank you in advance.

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

If the variable is character it would be better just create a SAS date variable and assign the desired format for use.

If the variable is already as SAS date variable use the mmddyy10. format.

 

Best is to run Proc Contents on your data set and share the properties of the variable.

 

Here is an example of creating a SAS date valued variable from a character version:

data have;
  input x :$12. ;
datalines;
1950-04-13
1920-02-26
1940-03-23
;

data want;
  set have;
  datevar = input(x,yymmdd10.);
  format datevar mmddyy10.;
run;

There are lots of existing formats to display dates with in SAS, and you can even create your own, so the SAS date valued numeric such as datevar is the better option.

 

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Assuming these are actual SAS dates and not character strings, you simply need a FORMAT statement.

 

format dateofbirth mmddyys10.;
--
Paige Miller
ballardw
Super User

If the variable is character it would be better just create a SAS date variable and assign the desired format for use.

If the variable is already as SAS date variable use the mmddyy10. format.

 

Best is to run Proc Contents on your data set and share the properties of the variable.

 

Here is an example of creating a SAS date valued variable from a character version:

data have;
  input x :$12. ;
datalines;
1950-04-13
1920-02-26
1940-03-23
;

data want;
  set have;
  datevar = input(x,yymmdd10.);
  format datevar mmddyy10.;
run;

There are lots of existing formats to display dates with in SAS, and you can even create your own, so the SAS date valued numeric such as datevar is the better option.

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 475 views
  • 0 likes
  • 3 in conversation