Hello,
I am having some trouble changing my date variable to a usable format. I have been able to change it to the 8 digit, MMDDYYYY format, but once I try to put the parathesis in to make it DD/MM/YYYY the numbers completely change and everything gets messy. I have offered photos for reference.
This is the only code I used for this:
data want;
set have;
format transaction_date MMDDYY10.;
run;
Thank you!
Looks like it is doing what you asked. Consider this little program.
data test;
input x;
year=year(x);
month=month(x);
day=day(x);
put (_all_) (= comma12.);
cards;
01082012
04112007
;
x=1,082,012 year=4,922 month=6 day=14 x=4,112,007 year=13,218 month=4 day=20
So one million days since 1960 is in the middle of the year 4922. 4 million days is after the start of the year 13,218!
First convert the value to an actual date (at least for the numbers that are valid dates). Then you can use the value as a date and attach any date format you want to use when display the values. Personally I avoid MMDDYY or DDMMYY format as whichever one you pick half of your audience will be confused.
fixed=input(put(transaction_date,Z8.),mmddyy8.);
format fixed yymmdd10.;
I'd also much rather use either YYMMDDD10. or E8601DA10. as a date format. This is the internationally standardized way to write dates and leaves no ambiguity.
Nearly 200 sessions are now available on demand in the Innovate Hub.
Watch Now →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.