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
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.);
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.);
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 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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.