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.

 

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore 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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2710 views
  • 3 likes
  • 3 in conversation