<?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 Re: How to prevent automatic conversion of date informat when facing partial date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-automatic-conversion-of-date-informat-when-facing/m-p/362900#M274854</link>
    <description>&lt;P&gt;I think the best answer to your question is: Don't make it guess!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your examples were attempts to get sas to read dates that had a 4 digit year and a two digit month:&lt;/P&gt;
&lt;PRE&gt;/* Example 1: */
data test;
  a= "201201";
run;
 
data test1;
  set test;
  format b date9.;
  b= input(a, yymmn6.);
run;
 
/* Example 2: */
data test;
  a= "201301";
run;
 
data test2;
set test;
  format b date9.;
  b= input(a, yymmn6.);
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
    <pubDate>Tue, 30 May 2017 22:10:59 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2017-05-30T22:10:59Z</dc:date>
    <item>
      <title>How to prevent automatic conversion of date informat when facing partial date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-automatic-conversion-of-date-informat-when-facing/m-p/362896#M274853</link>
      <description>&lt;P&gt;I recently found that SAS has its own "black box" when it detects partial date. The reason I call it 'black box' is that we don't know what it does when&amp;nbsp;it reads in partial date.&lt;/P&gt;&lt;P&gt;Example 1:&lt;/P&gt;&lt;P&gt;1) &amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;a= "201201";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test2;&lt;BR /&gt;set test;&lt;BR /&gt;b= input(a, yymmdd8.);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result: b=22250 (This is equivalent to 2020Dec01), which means SAS automatically reads the date as yymmdd6. when it can't find the last 2 digits.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example 2:&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;a= "201301";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test2;&lt;BR /&gt;set test;&lt;BR /&gt;b= input(a, yymmdd8.);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result: b= . (missing). Clearly, &lt;SPAN&gt;"201301" can't be read in as 'yymmdd6.' because there is no 13th month in a year. Then SAS finally gives it up and assigns missing value.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;How do we make sure SAS doesn't do this auto conversion? Also who knows what this 'black box' actually does besides this situation?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 21:54:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-automatic-conversion-of-date-informat-when-facing/m-p/362896#M274853</guid>
      <dc:creator>sunshinezb1990</dc:creator>
      <dc:date>2017-05-30T21:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent automatic conversion of date informat when facing partial date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-automatic-conversion-of-date-informat-when-facing/m-p/362900#M274854</link>
      <description>&lt;P&gt;I think the best answer to your question is: Don't make it guess!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your examples were attempts to get sas to read dates that had a 4 digit year and a two digit month:&lt;/P&gt;
&lt;PRE&gt;/* Example 1: */
data test;
  a= "201201";
run;
 
data test1;
  set test;
  format b date9.;
  b= input(a, yymmn6.);
run;
 
/* Example 2: */
data test;
  a= "201301";
run;
 
data test2;
set test;
  format b date9.;
  b= input(a, yymmn6.);
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 22:10:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-automatic-conversion-of-date-informat-when-facing/m-p/362900#M274854</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-05-30T22:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent automatic conversion of date informat when facing partial date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-automatic-conversion-of-date-informat-when-facing/m-p/362901#M274855</link>
      <description>&lt;P&gt;This is documented (i.e. it is demonstrated in the example) in the &lt;A href="http://support.sas.com/documentation/cdl/en/leforinforref/69823/HTML/default/viewer.htm#n18uyqeusnl0fxn1d9pvhm49j4za.htm" target="_self"&gt;YYMMDDw. informat&lt;/A&gt;&amp;nbsp;documentation.&amp;nbsp; The box is not as black as you might think.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 22:13:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-automatic-conversion-of-date-informat-when-facing/m-p/362901#M274855</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-05-30T22:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent automatic conversion of date informat when facing partial date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-automatic-conversion-of-date-informat-when-facing/m-p/363120#M274856</link>
      <description>&lt;P&gt;Yeah, the example does answer my question. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 15:22:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-prevent-automatic-conversion-of-date-informat-when-facing/m-p/363120#M274856</guid>
      <dc:creator>sunshinezb1990</dc:creator>
      <dc:date>2017-05-31T15:22:08Z</dc:date>
    </item>
  </channel>
</rss>

