In the code below everything is working fine.
DATA NEW;
NUMDT=20081990;
CHRDT=PUT(NUMDT,8.);
SASDT=INPUT(CHRDT,DDMMYY8.);
FORMAT SASDT DATE9.;
RUN;
but in the below code:
DATA NEW;
NUMDT=20081990;
CHRDT=PUT(NUMDT,date7.);
SASDT=INPUT(CHRDT,DDMMYY8.);
FORMAT SASDT DATE9.;
RUN;
it was not working fine.
can anyone please when exactly should i need to mention in put-format as date7.
When should you use the DATE7 format? Never.
The DATE7 format uses two-digit years, which introduces pitfalls and complications that are a major headache. For example, try @novinosrin 's program, but instead of using 20081990, use 20081915 as your original date. You will end up with a different date than you started with.
DATA NEW1;
NUMDT=20081990;
temp=input(PUT(NUMDT,8.),ddmmyy8.);
CHRDT=put(temp,date7.);
SASDT=INPUT(CHRDT,date7.);
FORMAT SASDT DATE9.;
RUN;
The temp variable is just reading ease and eyesight
When should you use the DATE7 format? Never.
The DATE7 format uses two-digit years, which introduces pitfalls and complications that are a major headache. For example, try @novinosrin 's program, but instead of using 20081990, use 20081915 as your original date. You will end up with a different date than you started with.
The variable NUMDT in your programs does NOT contain a date. It has the value 20,081,990. The date value for the '20AUG1990'd is 11,189 since it is that number of days after '01JAN1960'd. In the second program you are treating it as if it was a date. But over 20 million days is almost 55,000 years.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.