<?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 Reading in data in date format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-data-in-date-format/m-p/773959#M245931</link>
    <description>&lt;PRE&gt;I am trying to read in some data as a date. Here are four honest tries that fail in various ways.&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=""&gt;*error - "expecting a name";
data clinical;
input
ID $ 1-2
visit_date MMDDYY10. 4-13  
group $ 15
;
datalines;
01 03/12/1998 D
02 04/15/2008 P
03 11/30/2009 J
;
run;


*error - "expecting a name";
data clinical;
input
ID $ 1-2
visit_date 4-13 MMDDYY10. 
group $ 15
;
datalines;
01 03/12/1998 D
02 04/15/2008 P
03 11/30/2009 J
;
run;

*this works but the date is not a date;
data clinical;
input
ID $ 1-2
visit_date $ 4-13 
group $ 15
;
datalines;
01 03/12/1998 D
02 04/15/2008 P
03 11/30/2009 J
;
run;

*error - invalid data;
data clinical;
informat visit_date MMDDYY10.;
input
ID $ 1-2
visit_date 4-13 
group $ 15
;
datalines;
01 03/12/1998 D
02 04/15/2008 P
03 11/30/2009 J
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 13 Oct 2021 15:32:37 GMT</pubDate>
    <dc:creator>fpb1</dc:creator>
    <dc:date>2021-10-13T15:32:37Z</dc:date>
    <item>
      <title>Reading in data in date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-data-in-date-format/m-p/773959#M245931</link>
      <description>&lt;PRE&gt;I am trying to read in some data as a date. Here are four honest tries that fail in various ways.&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=""&gt;*error - "expecting a name";
data clinical;
input
ID $ 1-2
visit_date MMDDYY10. 4-13  
group $ 15
;
datalines;
01 03/12/1998 D
02 04/15/2008 P
03 11/30/2009 J
;
run;


*error - "expecting a name";
data clinical;
input
ID $ 1-2
visit_date 4-13 MMDDYY10. 
group $ 15
;
datalines;
01 03/12/1998 D
02 04/15/2008 P
03 11/30/2009 J
;
run;

*this works but the date is not a date;
data clinical;
input
ID $ 1-2
visit_date $ 4-13 
group $ 15
;
datalines;
01 03/12/1998 D
02 04/15/2008 P
03 11/30/2009 J
;
run;

*error - invalid data;
data clinical;
informat visit_date MMDDYY10.;
input
ID $ 1-2
visit_date 4-13 
group $ 15
;
datalines;
01 03/12/1998 D
02 04/15/2008 P
03 11/30/2009 J
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Oct 2021 15:32:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-data-in-date-format/m-p/773959#M245931</guid>
      <dc:creator>fpb1</dc:creator>
      <dc:date>2021-10-13T15:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in data in date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-data-in-date-format/m-p/773962#M245934</link>
      <description>Already answered here:&lt;BR /&gt;&lt;A href="https://stackoverflow.com/questions/69558104/sas-how-can-i-read-in-date-data" target="_blank"&gt;https://stackoverflow.com/questions/69558104/sas-how-can-i-read-in-date-data&lt;/A&gt;</description>
      <pubDate>Wed, 13 Oct 2021 15:36:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-data-in-date-format/m-p/773962#M245934</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-13T15:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in data in date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-data-in-date-format/m-p/773973#M245941</link>
      <description>&lt;P&gt;Nice tries, but not quite there. Go review the documentation links below, which should help you out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/basess/p0er6damfbjifwn1ih1b1tacw5zj.htm" target="_self"&gt;Working with Dates in the SAS System&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n0oaql83drile0n141pdacojq97s.htm" target="_self"&gt;Input Statement&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problems you are having are down to mixing column input and formatted input, for the first two attempts.&amp;nbsp;&lt;BR /&gt;The third attempt is just reading in a string.&lt;/P&gt;
&lt;P&gt;The fourth attempts to read the date as a number, but 03/12/1998 isn't a number.&lt;BR /&gt;&lt;BR /&gt;Look to use just formatted input.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 16:11:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-data-in-date-format/m-p/773973#M245941</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2021-10-13T16:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in data in date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-data-in-date-format/m-p/773979#M245944</link>
      <description>Sorry for cross-posting. A friend suggested this solution but it seems awkward.&lt;BR /&gt;&lt;BR /&gt;data clinical;&lt;BR /&gt;input&lt;BR /&gt;name $ 1-12&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/83330"&gt;@13&lt;/a&gt; visit_date MMDDYY10.&lt;BR /&gt;group $ 25 ;&lt;BR /&gt;datalines;&lt;BR /&gt;John Turner 03/12/1998 D&lt;BR /&gt;Mary Jones 04/15/2008 P&lt;BR /&gt;Joe Sims 11/30/2009 J&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 13 Oct 2021 16:21:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-data-in-date-format/m-p/773979#M245944</guid>
      <dc:creator>fpb1</dc:creator>
      <dc:date>2021-10-13T16:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in data in date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-data-in-date-format/m-p/773984#M245947</link>
      <description>&lt;P&gt;That's mixing 3 different input methods, column, formatted and list (see my reply below).&lt;BR /&gt;Although that's valid, I would recommend using the same input method, unless there is a reason not to.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 16:31:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-data-in-date-format/m-p/773984#M245947</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2021-10-13T16:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in data in date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-data-in-date-format/m-p/773990#M245948</link>
      <description>&lt;P&gt;Thanks. Though the SAS documentation you referred me to itself mixes and matches styles:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;libname&lt;/SPAN&gt;&lt;SPAN&gt; mylib &lt;/SPAN&gt;&lt;SPAN class=""&gt;'&lt;EM&gt;permanent-data-library&lt;/EM&gt;'&lt;/SPAN&gt;&lt;SPAN class=""&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;data&lt;/SPAN&gt;&lt;SPAN&gt; mylib&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;tourdates&lt;/SPAN&gt;&lt;SPAN class=""&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;infile&lt;/SPAN&gt; &lt;SPAN class=""&gt;'&lt;EM&gt;input-file&lt;/EM&gt;'&lt;/SPAN&gt;&lt;SPAN class=""&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;input &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Country &lt;SPAN class=""&gt;$&lt;/SPAN&gt; &lt;SPAN class=""&gt;1&lt;/SPAN&gt;&lt;SPAN class=""&gt;-&lt;/SPAN&gt;&lt;SPAN class=""&gt;11&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;@&lt;/SPAN&gt;&lt;SPAN class=""&gt;13&lt;/SPAN&gt; DepartureDate date9&lt;SPAN class=""&gt;.&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Nights&lt;SPAN class=""&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;run&lt;/SPAN&gt;&lt;SPAN class=""&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 16:48:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-data-in-date-format/m-p/773990#M245948</guid>
      <dc:creator>fpb1</dc:creator>
      <dc:date>2021-10-13T16:48:12Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in data in date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-data-in-date-format/m-p/774117#M245981</link>
      <description>&lt;P&gt;I know this may sound old-school, but sometimes sticking to proven methods is useful:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data clinical;
  /* define all variables in the order you want them in the dataset */
   length 
      ID $ 2
      visit_date 8
      group $ 1
   ;
   /* supply informat and format for those variables needing special treatment */
   informat visit_date mmddyy10.;
   format visit_date date9.;

   /* just list the variables in the order in which they are in the data source */
   input ID visit_date group;

   datalines;
01 03/12/1998 D
02 04/15/2008 P
03 11/30/2009 J
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If more variables need a format, informat or label, then switching from length (+ informat, ...) to attrib can improve readability.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 05:41:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-data-in-date-format/m-p/774117#M245981</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-10-14T05:41:53Z</dc:date>
    </item>
  </channel>
</rss>

