<?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: Importing difficult txt file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-difficult-txt-file/m-p/744539#M233259</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;And because, as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;noted, you have a fixed width text file, you have a very easy program to write in a data step.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If the dictionary has the correct columns.&lt;/P&gt;</description>
    <pubDate>Fri, 28 May 2021 19:58:44 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-05-28T19:58:44Z</dc:date>
    <item>
      <title>Importing difficult txt file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-difficult-txt-file/m-p/744530#M233256</link>
      <description>&lt;P&gt;hello!&lt;/P&gt;&lt;P&gt;I am trying to import a txt file, but I am having difficulty because I do not understand the delimiter in the file.I originally thought it was space delimited (code below), but the variables and columns do not match up.&amp;nbsp;I have attached a sample of the data and data dictionary&amp;nbsp;below. The end result should be 50 variables, not all will have values. Any assistance in making the variables and columns matched up would be much appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;import&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;OUT&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=mydata&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;datafile&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;= &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"\\computer\data\data sample.txt"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;DBMS&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=dlm REPLACE;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 May 2021 19:33:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-difficult-txt-file/m-p/744530#M233256</guid>
      <dc:creator>kbanders</dc:creator>
      <dc:date>2021-05-28T19:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: Importing difficult txt file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-difficult-txt-file/m-p/744533#M233257</link>
      <description>You have a fixed width file/column input, not a delimited file.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://stackoverflow.com/questions/27596072/reading-fixed-width-file-spaces-are-recognized" target="_blank"&gt;https://stackoverflow.com/questions/27596072/reading-fixed-width-file-spaces-are-recognized&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n13ejk9swz5vrbn0z34iazfrp0wp.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n13ejk9swz5vrbn0z34iazfrp0wp.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 28 May 2021 19:42:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-difficult-txt-file/m-p/744533#M233257</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-28T19:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: Importing difficult txt file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-difficult-txt-file/m-p/744537#M233258</link>
      <description>&lt;P&gt;And because, as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;noted, you have a fixed width text file, you have a very easy program to write in a data step.&lt;/P&gt;</description>
      <pubDate>Fri, 28 May 2021 19:55:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-difficult-txt-file/m-p/744537#M233258</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-05-28T19:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: Importing difficult txt file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-difficult-txt-file/m-p/744539#M233259</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;And because, as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;noted, you have a fixed width text file, you have a very easy program to write in a data step.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If the dictionary has the correct columns.&lt;/P&gt;</description>
      <pubDate>Fri, 28 May 2021 19:58:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-difficult-txt-file/m-p/744539#M233259</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-05-28T19:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: Importing difficult txt file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-difficult-txt-file/m-p/744576#M233274</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/366628"&gt;@kbanders&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;You have simple reading to be done.&lt;/P&gt;
&lt;P&gt;Unfortunately I see error in your dictionary file.&lt;BR /&gt;I have created a proof of concept code you can use it to create your code which you may use at basis. Make changes as you may need. I am attaching my data file too.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
Length Mem_id $10 Fam_mem_id $2 Claim_numbr $15;
infile "/Path_to_your_file/sample.txt"  truncover;
input @1 Mem_id $ @12 Fam_mem_id $ @14 Claim_numbr $;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;My sample data is attached.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 29 May 2021 02:21:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-difficult-txt-file/m-p/744576#M233274</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2021-05-29T02:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: Importing difficult txt file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-difficult-txt-file/m-p/744584#M233277</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/366628"&gt;@kbanders&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Should you still have problems importing your data after reading through the docu links shared on how to impute fixed length records then please post a data dictionary and data that matches.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also post the data step code you've already developed and can't make fully working. If there is a header section in your data then use option FIRSTOBS=&amp;lt;some number&amp;gt; on the Infile statement to only start imputing the data portion of your .txt file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you look at the Excel you've shared then:&lt;/P&gt;
&lt;P&gt;- Tab Header Record indicates that there is a header record in your data. The txt file you've shared doesn't have such a header&lt;/P&gt;
&lt;P&gt;- Tab Summary shows #REF instead of the start &amp;amp; end positions of the data (I could fix this issue)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And "worst" of all: In your .txt file the data in your first "column" is a string of 10 digits. This doesn't match your data dictionary where the first variable MBRID goes from position 1 to 30.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1622261598240.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/59878i59F6C3F7A40F07A0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1622261598240.png" alt="Patrick_0-1622261598240.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need further help then please post your data dictionary as .csv because many people won't download and open .xlsx&lt;/P&gt;</description>
      <pubDate>Sat, 29 May 2021 04:17:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-difficult-txt-file/m-p/744584#M233277</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-05-29T04:17:14Z</dc:date>
    </item>
  </channel>
</rss>

