BookmarkSubscribeRSS Feed
katies
Calcite | Level 5

I'm using an Access database that generates a 16-digit date time (e.g. 30May2019 0:00:00.0000). 

 

SAS imports this as a numeric field with format datetime16. How do I change it to a SAS datetime? I'm trying the code below, but I end up with a numeric field, not a date. 

 

Induct1=Input(put(InductDateActual,datetime16.), datetime16.);

 

6 REPLIES 6
Tom
Super User Tom
Super User

@katies wrote:

I'm using an Access database that generates a 16-digit date time (e.g. 30May2019 0:00:00.0000). 

 

SAS imports this as a numeric field with format datetime16. How do I change it to a SAS datetime? I'm trying the code below, but I end up with a numeric field, not a date. 

 

Induct1=Input(put(InductDateActual,datetime16.), datetime16.);

 


I don't understand the question. If it is a numeric variable with a DATETIME type format, like DATETIME itself, attached to it then it IS a SAS datetime value.  Do the values not look right when printed?  Do you want to print thme using a different format?  Like DATETIME20. ? Or DTDATE9. ?

katies
Calcite | Level 5

When I try to manipulate it, I end up with missing values or asterisks.

 

E.g. datepart(InductDateActual); returns only missing values. 

 

PGStats
Opal | Level 21

Asterisks may only mean that the display area is not wide enough. Try making it wider to display the formatted value.

PG
katies
Calcite | Level 5

I'm getting missing values from the datepart function, not asterisks. 

FreelanceReinh
Jade | Level 19

@katies wrote:

I'm getting missing values from the datepart function, not asterisks. 


This happens if the argument of the datepart function is either itself missing or invalid or out of range (like from a year <1582 or >20000).

 

To give us a bigger picture, please show us the output of the PROC MEANS step below:

proc means data=your_dataset n nmiss min q1 median q3 max;
var InductDateActual;
run;
Tom
Super User Tom
Super User

@katies wrote:

When I try to manipulate it, I end up with missing values or asterisks.

 

E.g. datepart(InductDateActual); returns only missing values. 

 


For that function to return a missing value the variable INDUCTDATEACTUAL must have a missing value.  All it basically does is convert seconds to days by dividing by the number of seconds in a day.

 

Check your variable. Check your code for typos or other mistakes.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 6 replies
  • 1010 views
  • 1 like
  • 4 in conversation