BookmarkSubscribeRSS Feed
jcis7
Pyrite | Level 9

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!

4 REPLIES 4
ballardw
Super User

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.

jcis7
Pyrite | Level 9

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?

ballardw
Super User

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.

jcis7
Pyrite | Level 9

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 4 replies
  • 1134 views
  • 0 likes
  • 2 in conversation