<?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 can't import date data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/can-t-import-date-data/m-p/628526#M185749</link>
    <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pretty new to SAS, so I apologize in advance. I'm trying to import the attached dataset, but I'm having an issue getting it to read the DOB column.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;DATA employees;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;&amp;nbsp;INFILE "C:\Users\dlobsien\Desktop\employees.txt" dsd;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;&amp;nbsp;INPUT SSN $11. Name $17. DOB DATE.9 PayGrade $57-60 Salary COMMA10. Position :$27.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;&amp;nbsp;TITLE employee data;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;It just shows all the observations under this column as missing data. Everything else reads as I want it to.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;I have also tried putting &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/25608"&gt;@xx&lt;/a&gt; before it as well entering the following with no success:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;INFORMAT DOB ANYDTDTE.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;INPUT ... DOB Pay...;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;FORMAT DOB DATE9. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;If anyone could provide any help it would be greatly appreciated.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 01 Mar 2020 07:51:17 GMT</pubDate>
    <dc:creator>Damon1</dc:creator>
    <dc:date>2020-03-01T07:51:17Z</dc:date>
    <item>
      <title>can't import date data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-t-import-date-data/m-p/628526#M185749</link>
      <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pretty new to SAS, so I apologize in advance. I'm trying to import the attached dataset, but I'm having an issue getting it to read the DOB column.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;DATA employees;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;&amp;nbsp;INFILE "C:\Users\dlobsien\Desktop\employees.txt" dsd;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;&amp;nbsp;INPUT SSN $11. Name $17. DOB DATE.9 PayGrade $57-60 Salary COMMA10. Position :$27.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;&amp;nbsp;TITLE employee data;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;It just shows all the observations under this column as missing data. Everything else reads as I want it to.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;I have also tried putting &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/25608"&gt;@xx&lt;/a&gt; before it as well entering the following with no success:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;INFORMAT DOB ANYDTDTE.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;INPUT ... DOB Pay...;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;FORMAT DOB DATE9. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;If anyone could provide any help it would be greatly appreciated.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Mar 2020 07:51:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-t-import-date-data/m-p/628526#M185749</guid>
      <dc:creator>Damon1</dc:creator>
      <dc:date>2020-03-01T07:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: can't import date data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-t-import-date-data/m-p/628531#M185755</link>
      <description>&lt;P&gt;You have a fixed-width layout, so you have to use formatted input (as you did), but because of the white space in between you need to use position indicators. You must take care of exact positioning.&lt;/P&gt;
&lt;P&gt;Name seems to start at position 16 (11 characters SSN, 4 characters space). Inspect your file with a good editor (notepad++) that shows the cursor position.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Mar 2020 08:39:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-t-import-date-data/m-p/628531#M185755</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-01T08:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: can't import date data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-t-import-date-data/m-p/628536#M185757</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/312620"&gt;@Damon1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The basic approach for fixed width is to specify the start and end column for each variable.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Could you please try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA employees;
	INFILE "C:\Users\dlobsien\Desktop\employees.txt" dsd;
	INPUT SSN $ 1-11 Name $ 16-32 DOB:DATE9. PayGrade $57-60 Salary:DOLLAR10. Position $ 73-99;
	FORMAT DOB DATE9. Salary DOLLAR10.;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
      <pubDate>Sun, 01 Mar 2020 09:46:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-t-import-date-data/m-p/628536#M185757</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-03-01T09:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: can't import date data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-t-import-date-data/m-p/628540#M185758</link>
      <description>&lt;P&gt;Code, tested with your file with UE on a Mac:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data employees;
infile '/folders/myfolders/employees.txt' truncover;
input
  @1  ssn       $11.
  @16 name      $30.
  @47 dob       date9.
  @57 paygrade  $4.
  @62 salary    dollar10.
  @73 position  $30.
;
format
  dob e8601da10.
  salary dollar12.2
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 01 Mar 2020 10:14:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-t-import-date-data/m-p/628540#M185758</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-01T10:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: can't import date data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-t-import-date-data/m-p/628565#M185771</link>
      <description>&lt;P&gt;so, this works to get the date in; however, now it gives me both the SSN and Name data under the "positions" column. I have tried setting the length and putting&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/282502"&gt;@72&lt;/a&gt; before it in the infile statement.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Mar 2020 18:03:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-t-import-date-data/m-p/628565#M185771</guid>
      <dc:creator>Damon1</dc:creator>
      <dc:date>2020-03-01T18:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: can't import date data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-t-import-date-data/m-p/628567#M185772</link>
      <description>worked perfectly! thanks so much!</description>
      <pubDate>Sun, 01 Mar 2020 18:06:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-t-import-date-data/m-p/628567#M185772</guid>
      <dc:creator>Damon1</dc:creator>
      <dc:date>2020-03-01T18:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: can't import date data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-t-import-date-data/m-p/628568#M185773</link>
      <description>&lt;P&gt;Ah, I should have used&amp;nbsp;@73 instead, which worked. Thanks so much &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Mar 2020 18:08:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-t-import-date-data/m-p/628568#M185773</guid>
      <dc:creator>Damon1</dc:creator>
      <dc:date>2020-03-01T18:08:29Z</dc:date>
    </item>
    <item>
      <title>Re: can't import date data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-t-import-date-data/m-p/628571#M185775</link>
      <description>&lt;P&gt;First thing it to fix the INFILE statement. You data is NOT delimited, so remove the DSD option. Also your lines might not have trailing blanks so add the TRUNCOVER option.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; INFILE "C:\Users\dlobsien\Desktop\employees.txt" truncover;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your fields appear to be in fixed columns but there is no way to use an informat when using a range of columns ( 10-20) in the INPUT statement. So you need to read the DOB and SALARY fields differently.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) You can use formatted mode. Make sure to start in the right column. This is best if the field might be all blanks.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; INPUT SSN $ 1-11 Name $ 12-46 @47 DOB DATE9. PayGrade $57-60 @62 Salary COMMA11. Position $ 73-99 ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;2) Use list mode, but make sure there is something in the field. Use a period to indicate a missing value otherwise SAS will scan past the end of the field until it sees something to read.&amp;nbsp; Note that with list mode the width of the INFORMAT specification does not matter, the INPUT statement adjusts the width to match the width of the next thing on the line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2a) You can either add an INFORMAT statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; INPUT SSN $ 1-11 Name $ 12-46 DOB PayGrade $57-60 Salary Position $ 73-99 ;
 informat dob date. salary comma. ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;2b) Or us the colon modifier in front of the in-line informat specification.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;INPUT SSN $ 1-11 Name $ 12-46 DOB :date. PayGrade $57-60 Salary :comma. Position $ 73-99 ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here are a few of the lines from your attached file, with a ruler to see the column locations.&lt;/P&gt;
&lt;PRE&gt;         1         2         3         4         5         6         7         8         9
----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+
XXX-XX-3484    Edward Rogers                  27JUN1989 GR20 $4,653.23  Business Analyst
XXX-XX-3305    Steven Price                   30JUN1961 GR20 $5,581.94  Systems Engineer I
XXX-XX-2575    Donald Graham                  07MAR1959 GR26 $15,081.73 Human Resources Director&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Mar 2020 18:22:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-t-import-date-data/m-p/628571#M185775</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-01T18:22:12Z</dc:date>
    </item>
  </channel>
</rss>

