DATA Step, Macro, Functions and more

yearcutoff problem.

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

yearcutoff problem.

 

 

1)Suppose the YEARCUTOFF= system option is set to 1920. An input file contains the date expression 12/08/1925, which is being read with the MMDDYY8. informat. Which date will appear in your data?

 

: The answer is 08DEC2019  

 

I felt the answer would be 08DEC1925 , as 1920-2019 will be range if yearcutoff=1920. 

 

Experts pls help me out with this problem.

 

Thanks 

Raj


Accepted Solutions
Solution
‎09-12-2017 11:39 PM
Super User
Posts: 5,360

Re: yearcutoff problem.

Just saying the same thing in different words ...

 

The MMDDYY8 informat means, "Read 8 characters.  Expect them to be in month+day+year form.  Interpret and convert what you find within those 8 characters."

 

So the data contains 12/08/1925.  But the MMDDYY8 informat specifically instructs the software to read the first 8 of those 10 characters.  It never reads the "25" at the end, only the "12/08/19".

View solution in original post


All Replies
Super User
Posts: 19,063

Re: yearcutoff problem.

Your issue isn't with YEARCUTOFF per se, but with the format.

If it's MMDDYY10 - it uses the whole year. 

But if it's MMDDYY8 - it sees

 

12/08/19 -> 2019

Occasional Contributor
Posts: 9

Re: yearcutoff problem.

the date is 12/08/1925,

Highlighted
Super User
Posts: 3,233

Re: yearcutoff problem.

Your informat should be MMDDYY10. - the length includes the forward slashes. This is a data truncation problem - you are reading 12/08/19 when you should be reading 12/08/1925. The YEARCUTOFF option is irrelevant in this case as you have the complete date including the century.

Solution
‎09-12-2017 11:39 PM
Super User
Posts: 5,360

Re: yearcutoff problem.

Just saying the same thing in different words ...

 

The MMDDYY8 informat means, "Read 8 characters.  Expect them to be in month+day+year form.  Interpret and convert what you find within those 8 characters."

 

So the data contains 12/08/1925.  But the MMDDYY8 informat specifically instructs the software to read the first 8 of those 10 characters.  It never reads the "25" at the end, only the "12/08/19".

Occasional Contributor
Posts: 9

Re: yearcutoff problem.

Thanks now got it Smiley Happy
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 202 views
  • 7 likes
  • 4 in conversation