<?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 add a date condition while doing infile? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-date-condition-while-doing-infile/m-p/937007#M368204</link>
    <description>&lt;P&gt;Currently the earliest date that SAS will use is 1 Jan 1582 and relates to when certain countries adopted the Gregorian calendar.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Custom informat and formats can approximate the behavior requested: (Note to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/466540"&gt;@Aashi07&lt;/a&gt; if your other dates are in Day Month Year order use DDMMYY10. below)&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
  invalue  mydates
  '01/01/1900'=.M
  other = [mmddyy10.]
  ;
  value mydates
  .M = '01/01/0001'
  other=[mmddyy10.]
  ;
run;

data example;
   input date mydates.;
   format date mydates.;
datalines;
01/01/1900
12/31/2021
02/01/2023
;&lt;/PRE&gt;
&lt;P&gt;Assign a special missing, like the .M and use a custom format to display the special missing with desired appearance when needed. The missing values will not be included in any calculations unless using an option that specifies missing values will be used.&lt;/P&gt;</description>
    <pubDate>Wed, 24 Jul 2024 15:18:11 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-07-24T15:18:11Z</dc:date>
    <item>
      <title>How to add a date condition while doing infile?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-date-condition-while-doing-infile/m-p/936939#M368189</link>
      <description>&lt;P class="lia-align-left"&gt;For task:&amp;nbsp;&lt;EM&gt;If in the date columns there is 01/01/1900, replace with 01/01/0001,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I tried the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data work.CGDM_IMP_PPLC;
              infile "&amp;amp;chemin_CGDM./W6_Extraction_CGDM_PPLC.csv" 
              delimiter='|' firstobs=2 lrecl=32767 missover dsd termstr=lf encoding='utf-8';
  
          format 
        DATE_DONNEES DDMMYY10. 
        DATE_ENTREE_ENTREPRISE DDMMYY10.
        DATE_SORTIE_ENTREPRISE DDMMYY10.
        DATE_ENTREE_ETABL DDMMYY10.
        DATE_SORTIE_ETABL DDMMYY10.
        IND_VIP 1.
        IND_SALARIE_DCD 1.
              ;
              input
       SOURCE
        DATE_DONNEES :YYMMDD10.
       DATE_ENTREE_ENTREPRISE :YYMMDD10.
        DATE_SORTIE_ENTREPRISE :YYMMDD10.
        DATE_ENTREE_ETABL :YYMMDD10.
        DATE_SORTIE_ETABL :YYMMDD10.
        IND_VIP
        IND_SALARIE_DCD

              ;
     if DATE_SORTIE_ENTREPRISE = '01/01/1900'd
           then DATE_SORTIE_ENTREPRISE = '01/01/0001'd;

run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I am obtaining this error:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Aashi07_1-1721814376188.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/98689i6D714CD5E9825C1B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Aashi07_1-1721814376188.png" alt="Aashi07_1-1721814376188.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2024 09:47:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-date-condition-while-doing-infile/m-p/936939#M368189</guid>
      <dc:creator>Aashi07</dc:creator>
      <dc:date>2024-07-24T09:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a date condition while doing infile?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-date-condition-while-doing-infile/m-p/936940#M368190</link>
      <description>&lt;P&gt;In an IF statement, you MUST use the date literal&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if DATE_SORTIE_ENTREPRISE = '01JAN1900'd ...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to search for 01/01/1900.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I do not believe it is possible to assign a date of 01/01/0001, and so I think your task is impossible. Why do you want 01/01/0001 anyway? Why not just assign a missing value?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2024 10:33:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-date-condition-while-doing-infile/m-p/936940#M368190</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-07-24T10:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a date condition while doing infile?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-date-condition-while-doing-infile/m-p/937007#M368204</link>
      <description>&lt;P&gt;Currently the earliest date that SAS will use is 1 Jan 1582 and relates to when certain countries adopted the Gregorian calendar.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Custom informat and formats can approximate the behavior requested: (Note to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/466540"&gt;@Aashi07&lt;/a&gt; if your other dates are in Day Month Year order use DDMMYY10. below)&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
  invalue  mydates
  '01/01/1900'=.M
  other = [mmddyy10.]
  ;
  value mydates
  .M = '01/01/0001'
  other=[mmddyy10.]
  ;
run;

data example;
   input date mydates.;
   format date mydates.;
datalines;
01/01/1900
12/31/2021
02/01/2023
;&lt;/PRE&gt;
&lt;P&gt;Assign a special missing, like the .M and use a custom format to display the special missing with desired appearance when needed. The missing values will not be included in any calculations unless using an option that specifies missing values will be used.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2024 15:18:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-date-condition-while-doing-infile/m-p/937007#M368204</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-07-24T15:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a date condition while doing infile?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-date-condition-while-doing-infile/m-p/937009#M368205</link>
      <description>&lt;P&gt;Date literals require a string that the DATE informat can convert to a date.&lt;/P&gt;
&lt;P&gt;But you cannot have a date before 1582.&amp;nbsp; So if the CSV file use strings like 0001/01/01 they will be read by the YYMMDD informat as missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So it sounds like you just need to change the IF statement to assign a missing value instead.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if DATE_SORTIE_ENTREPRISE = '01JAN1900'd
  then DATE_SORTIE_ENTREPRISE = .
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Or you could assign one of the 27 other special missing values instead.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2024 15:30:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-date-condition-while-doing-infile/m-p/937009#M368205</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-07-24T15:30:03Z</dc:date>
    </item>
  </channel>
</rss>

