BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rkdubey84
Obsidian | Level 7

I am writing the following code to Obtain DTM1 = 03JUN2013:09:15:00.

But Instead it gives me the value of DTM1 =  07JUL****:09:15:00.

 

I am not sure how is it converting 03062013 into 07JULY**** .

 

Plz. Help.

  

%Macro DTX(d);
Data FA.ACC_NBNSFinal; Set FA.ACC_NBNSFinal_&d;
OrdDate = &d; /*'&d'd Gives Error*/
Format OrdDate Date9.;
DTM1=dhms(OrdDate,0,0,T);
format DTM1 datetime22.;
Drop OrdDate;
run;
%Mend;
%DTX(03062013);

 

Thanks in Advance.

 

Ritesh

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

SAS is seeing it as a number, specifically the number of days from Jan 1, 1960. 

 

First convert it to a SAS date or pass as a date literal. 

 

%dtx('03Jun2016'd);

 

Or convert it to a date, 

 

ordDafe = input(put(&d, 8.), ddmmyy8.);

 

 

View solution in original post

5 REPLIES 5
Reeza
Super User

SAS is seeing it as a number, specifically the number of days from Jan 1, 1960. 

 

First convert it to a SAS date or pass as a date literal. 

 

%dtx('03Jun2016'd);

 

Or convert it to a date, 

 

ordDafe = input(put(&d, 8.), ddmmyy8.);

 

 

rkdubey84
Obsidian | Level 7
OrdDate = input(put(&d, 8.), ddmmyy8.);

Worked the wonders for me.

Thanks a Ton Reeza 🙂
ballardw
Super User

A hint for future diagnosis: the appearance of **** indicates that SAS can't correctly display the value with the chosen format. When you see this in a DATE related context it usually means that the date is past the year 9999. A brief example:

 

data _null_;
   x = '15JAN10350'd;
   year = year(x);
   put x= best12. +1 'with date format'+1 x= date9. year=;
run;

Until someone convinces SAS that we need to display more than 4 digit years none of the existing date/datetime formats will display years after 9999 correctly.

 

rkdubey84
Obsidian | Level 7
@ballardw: Hahahaha... That's quite a proactive thinking for the near future. 🙂
ballardw
Super User

@rkdubey84 wrote:
@ballardw: Hahahaha... That's quite a proactive thinking for the near future. 🙂

I was working on some data prior to the year 2000 and kept getting requests about whether the way I was handling data is SAS would be acceptable for Y2K issues. After about a dozen of those I did some tests with SAS date values to find the valid ranges and noted that they end 31 Dec 20000 for date literals: x='31DEC20000'd;

 

The questions stopped when I emphasized that the dates were good for most of the next 18,000 years.

 

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
  • 5 replies
  • 1041 views
  • 3 likes
  • 3 in conversation