BookmarkSubscribeRSS Feed

If I assume that my RDBMS supports ISO8601 for date, time, and datetime literals (and if it doesn't, it should), then it would be convenient if SAS did the same.

 

 

Sample Code:

 

%let date=%sysfunc(date(),e8601da.);
%let time=%sysfunc(time(),e8601tm.);
%let datetime=%sysfunc(datetime(),e8601dt.);

%put &=date;
%put &=time;
%put &=datetime;

My results as of the time of this post:

 

27         %put &=date;
DATE=2016-08-16
28         %put &=time;
TIME=10:32:06
29         %put &=datetime;
DATETIME=2016-08-16T10:32:06

I only have SQL Server to test against right now, but these values all "work" for SQL Server:

 

SELECT
	CAST('2016-08-16' AS DATE)
	,CAST('10:32:06' AS TIME)
	,CAST('2016-08-16T10:32:06' AS DATETIME)

But not for SAS:

 

data _null_;
   date="&date"d;
   time="&time"t;
   datetime="&datetime"dt;
   put
      date=date9.
      time=time.
      datetime=datetime.
   ;
run;

If SAS supported the ISO8601 standard, this would make the interchange of date, time, and datetime literals easier when querying data between SAS, RDBMS (implicit pass-through) and RDBMS (explicit pass-through).

11 Comments
ChrisNZ
Tourmaline | Level 20

@ScottBass

Example #2 looks like a bug that should be reported to tech support.