BookmarkSubscribeRSS Feed
chappy
Calcite | Level 5

I am trying to convert datetime data to date data (Date9. format). The data was imported from MS Access (.mdb file created in Access 97). I've tried using

data mylib.datanew;

set mylib.dataold;

informate birthdate date9.;

format birthdate date9.;

run;

I get 1.48867E9 instead of 05MAR2007. The log gives the following message ERROR: There was a problem with the format so BEST. was used. Any help appreciated Smiley Happy

5 REPLIES 5
Linlin
Lapis Lazuli | Level 10

try:

new=datepart(old-variable);

chappy
Calcite | Level 5

I tried this and now SAS has the new variable formatted as Best which is not any sensible date format. Could it be a problem with the SAS default formatting or is it something to do with the MS Access file format?

Thanks!

art297
Opal | Level 21

Did you assign a format to the new variable (e.g., date9.)?

PGStats
Opal | Level 21

You can even use

birthdate = datepart(birthdate);

if your objective is simply to remove the hour part from a date in an Access database table, you may leave the variable as a datetime value and use:

format birthdate datetime20.;

birthdate = intnx("DTDAY",birthdate,0);

PG

PG
chappy
Calcite | Level 5

Thanks for all of your "codes of wisdom". I finally have figured out what works.

data mylib.data;                                                                                                                

set mylib.data;                                                                                                                      

birthdate=datepart(birthdate);                                                                                                         

format birthdate date9.;                                                                                                               

run;

This returns birthdate values in the format 01JAN1960.

Thanks again Smiley Happy

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 5 replies
  • 1324 views
  • 0 likes
  • 4 in conversation