<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Date Conversion using datapart in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-Conversion-using-datapart/m-p/988667#M380149</link>
    <description>&lt;P&gt;Hi SAS experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was routinely converting DATE given in the format:&lt;/P&gt;
&lt;TABLE width="362"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="187"&gt;Number ID&lt;/TD&gt;
&lt;TD width="175"&gt;Old_Format&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;12MAR2025:00:00:00.000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;17MAR2025:00:00:00.000&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;using&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;select datepart(Old_Format) as New_Format format=mmddyy10.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;from DATASET;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And that was working well, but suddenly I've started receiving the following error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Some character data was lost during transcoding in the dataset DATESET. Either the data contains characters that are not representable in the new encoding or truncation occurred during transcoding.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not able to see what changed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any ideas are appreciated.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much for your time.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Batta&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 May 2026 12:49:29 GMT</pubDate>
    <dc:creator>Batta</dc:creator>
    <dc:date>2026-05-26T12:49:29Z</dc:date>
    <item>
      <title>Date Conversion using datapart</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Conversion-using-datapart/m-p/988667#M380149</link>
      <description>&lt;P&gt;Hi SAS experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was routinely converting DATE given in the format:&lt;/P&gt;
&lt;TABLE width="362"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="187"&gt;Number ID&lt;/TD&gt;
&lt;TD width="175"&gt;Old_Format&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;12MAR2025:00:00:00.000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;17MAR2025:00:00:00.000&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;using&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;select datepart(Old_Format) as New_Format format=mmddyy10.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;from DATASET;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And that was working well, but suddenly I've started receiving the following error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Some character data was lost during transcoding in the dataset DATESET. Either the data contains characters that are not representable in the new encoding or truncation occurred during transcoding.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not able to see what changed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any ideas are appreciated.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much for your time.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Batta&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2026 12:49:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Conversion-using-datapart/m-p/988667#M380149</guid>
      <dc:creator>Batta</dc:creator>
      <dc:date>2026-05-26T12:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: Date Conversion using datapart</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Conversion-using-datapart/m-p/988668#M380150</link>
      <description>&lt;P&gt;Either the data being read has changed and it now has characters that cannot be converted into the encoding being used by the SAS session.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or you switched to a new SAS session that is using a different setting of the ENCODING system option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check the ENCODING system option. Check the encoding of the dataset you are reading from.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put ENCODING=%sysfunc(getoption(encoding));
proc contents data=DATASET;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2026 12:57:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Conversion-using-datapart/m-p/988668#M380150</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-05-26T12:57:17Z</dc:date>
    </item>
  </channel>
</rss>

