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

Hi all,

 

  My date of arrivals were in excel as '1/1/18' and there must have previously been some character code in the column, because when I imported to SAS it changed to $13. and looks like '43101' except it's now in character. Any ideas how to change it back to the original numeric date? Either mmddyy10 or ddmmyy10?

 

Data have;

DOA

43101

43101

43102

43103

43104

43105

data want;

DOA

1/1/18

1/1/18

1/2/18

1/3/18

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

To change the string values to date values first convert to a number and then adjust for the difference in how Excel and SAS count dates.  Then you can attach any date type format you want to have the values display in a human readable way.

date = input(doa,32.)+'30DEC1899'd ;
format date date9.;

 

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

To change the string values to date values first convert to a number and then adjust for the difference in how Excel and SAS count dates.  Then you can attach any date type format you want to have the values display in a human readable way.

date = input(doa,32.)+'30DEC1899'd ;
format date date9.;

 

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 16. 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
  • 1 reply
  • 986 views
  • 3 likes
  • 2 in conversation