<?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: Date format data in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Date-format-data/m-p/854968#M37678</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want the data step to read strings like '&lt;SPAN&gt;17/06/2020' from the text file then tell that by assigning the DDMMYY informat to the variable.&amp;nbsp; If you want the date values that generates to print in a way that humans can understand then attach a date type format.&amp;nbsp; It would recommend not using the DDMMYY or the MMDDYY format because either one will confuse 50% of your audience.&amp;nbsp; Use DATE or YYMMDD and you will not risk having users confuse January sixth for the first of June. Also you will want to use the DSD option when reading a delimited file. Otherwise empty values might cause SAS to misalign the columns.&amp;nbsp; And add the TRUNCOVER option in case any of the lines have fewer values that expected.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data farm;
  infile BSMB firstobs=2 dsd dlm=';' truncover;
  input Period THIPeriod Month THIIMonth ID breed Parity DIMMilk TOTALMilk 
        FAT FM PROTEIN PM SC SCS Dryingperiod Gestationperiod Nins LastI 
        Calvingdate previouscalving  CCinterval ICIf IIIplus trpi Icoit Concprate
        diestrus metestrus estrus proestrus  RT HR RR PS
  ;
  informat LastI Calvingdate previouscalving diestrus metestrus estrus proestrus ddmmyy.;
  format LastI Calvingdate previouscalving diestrus metestrus estrus proestrus yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;NOTE: You did not show what your CSV file looks like.&amp;nbsp;&lt;/STRONG&gt; So the actual date strings might be in a style that the DDMMYY informat cannot read.&amp;nbsp; That is because you posted a screenshot of some type of SPREADSHEET.&amp;nbsp;&lt;STRONG&gt; A CSV file is a text file.&lt;/STRONG&gt;&amp;nbsp; That is critical because a spreadsheet program, like EXCEL, might have changed how the date values are displayed after it read in the CSV file.&amp;nbsp;To share sample lines of of the text file just open it with any text editor (SAS editor will work) and copy and paste a few of the lines of text into the window you get when you press the Insert Code icon (looks like &amp;lt; / &amp;gt; ) on this forum's edit screen.&lt;/P&gt;</description>
    <pubDate>Sat, 21 Jan 2023 13:43:27 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-01-21T13:43:27Z</dc:date>
    <item>
      <title>Date format data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-format-data/m-p/854967#M37677</link>
      <description>&lt;P&gt;Hello, everyone!&lt;/P&gt;&lt;P&gt;I have variables in my CSV data, in date format like the calving date of 17/06/2020.&lt;/P&gt;&lt;P&gt;I do know how SAS can read all the CSV data.&lt;/P&gt;&lt;P&gt;I used this code to enter my data&lt;/P&gt;&lt;P&gt;filename BSMB'C:\Users\Ebtissem\Desktop\BSMB\ebtissem.csv';&lt;BR /&gt;data farm;&lt;BR /&gt;infile BSMB firstobs=2 dlm=';';&lt;BR /&gt;input Period THIPeriod Month THIIMonth ID breed Parity DIMMilk TOTALMilk FAT FM PROTEIN PM SC SCS Dryingperiod Gestationperiod Nins &lt;FONT color="#FF0000"&gt;LastI&lt;/FONT&gt; &lt;FONT color="#FF0000"&gt;Calvingdate&lt;/FONT&gt;&amp;nbsp;&lt;FONT color="#FF0000"&gt;previouscalving&lt;/FONT&gt;&amp;nbsp; CCinterval ICIf IIIplus trpi Icoit Concprate &lt;FONT color="#FF0000"&gt;diestrus&lt;/FONT&gt; &lt;FONT color="#FF0000"&gt;metestrus&lt;/FONT&gt; &lt;FONT color="#FF0000"&gt;estrus&lt;/FONT&gt; &lt;FONT color="#FF0000"&gt;proestrus&lt;/FONT&gt;&amp;nbsp; RT HR RR PS;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;PS: I write in red color the variables containing date format.&lt;/P&gt;&lt;P&gt;and here is&amp;nbsp;the first two rows'screenshot of some observations in CSV data.&lt;/P&gt;&lt;P&gt;How can I input the variables in the write format&amp;nbsp; and not obtain invalid data.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="alwaysgood_0-1674304019777.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79584i0052859A510A27ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="alwaysgood_0-1674304019777.png" alt="alwaysgood_0-1674304019777.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Jan 2023 12:27:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-format-data/m-p/854967#M37677</guid>
      <dc:creator>always-good</dc:creator>
      <dc:date>2023-01-21T12:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: Date format data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-format-data/m-p/854968#M37678</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want the data step to read strings like '&lt;SPAN&gt;17/06/2020' from the text file then tell that by assigning the DDMMYY informat to the variable.&amp;nbsp; If you want the date values that generates to print in a way that humans can understand then attach a date type format.&amp;nbsp; It would recommend not using the DDMMYY or the MMDDYY format because either one will confuse 50% of your audience.&amp;nbsp; Use DATE or YYMMDD and you will not risk having users confuse January sixth for the first of June. Also you will want to use the DSD option when reading a delimited file. Otherwise empty values might cause SAS to misalign the columns.&amp;nbsp; And add the TRUNCOVER option in case any of the lines have fewer values that expected.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data farm;
  infile BSMB firstobs=2 dsd dlm=';' truncover;
  input Period THIPeriod Month THIIMonth ID breed Parity DIMMilk TOTALMilk 
        FAT FM PROTEIN PM SC SCS Dryingperiod Gestationperiod Nins LastI 
        Calvingdate previouscalving  CCinterval ICIf IIIplus trpi Icoit Concprate
        diestrus metestrus estrus proestrus  RT HR RR PS
  ;
  informat LastI Calvingdate previouscalving diestrus metestrus estrus proestrus ddmmyy.;
  format LastI Calvingdate previouscalving diestrus metestrus estrus proestrus yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;NOTE: You did not show what your CSV file looks like.&amp;nbsp;&lt;/STRONG&gt; So the actual date strings might be in a style that the DDMMYY informat cannot read.&amp;nbsp; That is because you posted a screenshot of some type of SPREADSHEET.&amp;nbsp;&lt;STRONG&gt; A CSV file is a text file.&lt;/STRONG&gt;&amp;nbsp; That is critical because a spreadsheet program, like EXCEL, might have changed how the date values are displayed after it read in the CSV file.&amp;nbsp;To share sample lines of of the text file just open it with any text editor (SAS editor will work) and copy and paste a few of the lines of text into the window you get when you press the Insert Code icon (looks like &amp;lt; / &amp;gt; ) on this forum's edit screen.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Jan 2023 13:43:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-format-data/m-p/854968#M37678</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-01-21T13:43:27Z</dc:date>
    </item>
  </channel>
</rss>

