BookmarkSubscribeRSS Feed
Anindya
Calcite | Level 5

Hi,

 

I am trying to import XML file which has a date 02/29/1956. While importing the XML file I am encountering the following error - 

 

ERROR: Data contains invalid content for date datatype. Invalid content is 02/29/19.
occurred at or near line 3006, column 251

 

I have even used the YEARCUTOFF option but still facing the same error. Please help me in getting the issue resolved. 

filename xx temp;
libname xx xmlv2  '<folder>/Sample1.XML' automap=replace xmlmap=xx;

data entity;
set xx.entity;
run;
2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, not really going to be possible to work this out, would need to see the map and the xml part.  If that warning is the one you get, then it appears to be truncating the text, so I would check the xmlmap and see if there is any length constraint or format/informat applied there which may be affecting the read. 

ballardw
Super User

@Anindya wrote:

Hi,

 

I am trying to import XML file which has a date 02/29/1956. While importing the XML file I am encountering the following error - 

 

ERROR: Data contains invalid content for date datatype. Invalid content is 02/29/19.
occurred at or near line 3006, column 251

 

I have even used the YEARCUTOFF option but still facing the same error. Please help me in getting the issue resolved. 

filename xx temp;
libname xx xmlv2  '<folder>/Sample1.XML' automap=replace xmlmap=xx;

data entity;
set xx.entity;
run;

Compare the text in your question I highlighted in blue and in the error message in red. See a difference?

The error message would indicate that something is truncating the value to 6 characters. So the year is being read using only two digits, 19. The yearcutoff only effects how the last two years of a date would be treated. Since the 56 is apparently not there then you would be reading that year as either 1919 or 2019, neither of which can be a leap year (Feb 29 only occurring in such).

 

So either the value in the XML is not what you believe or perhaps the xmlmap was built incorrectly and is only using 8 instead of 10 characters. I would verify if other dates are correct as it is likely that you have a lot of dates from either 2019 or 1919 if the map is incorrect.

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
  • 2 replies
  • 1428 views
  • 2 likes
  • 3 in conversation