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

 

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.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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.

View solution in original post

3 REPLIES 3
novinosrin
Tourmaline | Level 20
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

Astounding
PROC Star

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.

Tom
Super User Tom
Super User

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.

SAS Innovate 2025: Register Now

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!

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
  • 3 replies
  • 774 views
  • 1 like
  • 4 in conversation