DATA Step, Macro, Functions and more

Import date from MS Acess to SAS

Reply
Regular Contributor
Posts: 192

Import date from MS Acess to SAS

I have a MS Access table with dates and am trying to import into SAS.

(i.e. 10/5/2007 in the MS Access table is imported into SAS as 05OCT2007:00:00:00 but it is still followed by many zeroes);the input mask  in the MS Acess Form is 99/99/0000;0   Also, datatype in MS Access is Date/Time

1) How do I:

     a) Convert to a SAS date? I tried the datepart function but I think datepart is only for a date/time that has hours and minutes, not hours, minutes and seconds.?

     b) Convert it back to mm/dd/yyyy so I can export back out into access without hving the 00:00:00 at the end?

Thanks!

Super User
Posts: 10,500

Re: Import date from MS Acess to SAS

The datepart function pulls the date from any valid SAS datetime value, seconds or fractions thereof don't matter.

Considering I've had dates, declared as DATE values, and entered in Access show 00:00:00.00 I'm not sure if your second part is possible.

Depending on how you are moving data to and from Access the engine should take care of the update but if you are putting the data back into the original table expect the 00:00 as that is most likely an Access feature. You may need to investigate date displays in Access to suppress the time component.

Regular Contributor
Posts: 192

Re: Import date from MS Acess to SAS

Thanks!!

I got SAS to convert the date/time into just the date.

But, how do I get SAS to convert or format the SAS date back into mm/dd/yyyy format within SAS?

Super User
Posts: 10,500

Re: Import date from MS Acess to SAS

Assign the format mmddyy10. to the variable. If possible the best is to use the statement:

format datevariablename mmddyy10.;

in a program that reads the data. Alternatively you may use Proc Datasets, opening either the column view or table view in explorer and clicking on the variable name/field you want to modify.

Regular Contributor
Posts: 192

Re: Import date from MS Acess to SAS

Thank you! I was trying to use an array and the input  or put statement and that did not work!

Ask a Question
Discussion stats
  • 4 replies
  • 333 views
  • 0 likes
  • 2 in conversation