<?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 read a text file with delimiter semicolon and header? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-text-file-with-delimiter-semicolon-and-header/m-p/721204#M223491</link>
    <description>&lt;P&gt;Don't waste time with PROC IMPORT when reading text files, in the end you are faster writing the code yourself:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
infile datalines dlm=";" dsd truncover firstobs=2;
input code :$1. description :$10. total;
datalines4;
code;description;total
1;hi;201
2;hey;301
3;good;401
;;;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For your actual file, replace the DATALINES keyword in the INFILE statement with your filename, and remove the DATALINES4; block.&lt;/P&gt;</description>
    <pubDate>Tue, 23 Feb 2021 07:55:46 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-02-23T07:55:46Z</dc:date>
    <item>
      <title>How to read a text file with delimiter semicolon and header?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-text-file-with-delimiter-semicolon-and-header/m-p/721094#M223423</link>
      <description>&lt;P&gt;Hi, everyone. I just started using SAS. I don't know how to import a text file.&lt;/P&gt;&lt;P&gt;Here an example of my text file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;code;description;total&lt;/P&gt;&lt;P&gt;1;hi;201&lt;/P&gt;&lt;P&gt;2;hey;301&lt;/P&gt;&lt;P&gt;3;good;401&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That's it. BTW I don't know the field length just that it's semicolon delimited.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just tried this but it doesn't work:&lt;/P&gt;&lt;DIV class="lia-message-subject"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;data Nombre_cuentas_cualit_1001&lt;BR /&gt;infile "C:\proyecto_sas_bv\Nombre_cuentas_cualit_1001.txt" dlm=';';&lt;BR /&gt;input code--total;&lt;BR /&gt;run;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2021 21:53:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-text-file-with-delimiter-semicolon-and-header/m-p/721094#M223423</guid>
      <dc:creator>eduarxj32</dc:creator>
      <dc:date>2021-02-22T21:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a text file with delimiter semicolon and header?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-text-file-with-delimiter-semicolon-and-header/m-p/721101#M223429</link>
      <description>&lt;P&gt;Use PROC IMPORT. Check the log to see the code generated. &lt;BR /&gt;&lt;BR /&gt;Or if you want to write a data step, look up the INFILE statement and see what options are available. FIRSTOBS tells SAS which line the data starts at.&lt;BR /&gt;You do need to explicilty list all your variables when you use this method though, your INPUT statement isn't valid here. If you listed all variables in a FORMAT or LENGTH statement ahead of time, that would work but you haven't in this case. &lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/faq/how-do-i-read-in-a-delimited-ascii-file-in-sas/" target="_blank" rel="noopener"&gt;https://stats.idre.ucla.edu/sas/faq/how-do-i-read-in-a-delimited-ascii-file-in-sas/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/370600"&gt;@eduarxj32&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi, everyone. I just started using SAS. I don't know how to import a text file.&lt;/P&gt;
&lt;P&gt;Here an example of my text file:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;code;description;total&lt;/P&gt;
&lt;P&gt;1;hi;201&lt;/P&gt;
&lt;P&gt;2;hey;301&lt;/P&gt;
&lt;P&gt;3;good;401&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's it. BTW I don't know the field length just that it's semicolon delimited.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just tried this but it doesn't work:&lt;/P&gt;
&lt;DIV class="lia-message-subject"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data Nombre_cuentas_cualit_1001&lt;BR /&gt;infile "C:\proyecto_sas_bv\Nombre_cuentas_cualit_1001.txt" dlm=';';&lt;BR /&gt;input code--total;&lt;BR /&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2021 22:02:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-text-file-with-delimiter-semicolon-and-header/m-p/721101#M223429</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-02-22T22:02:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a text file with delimiter semicolon and header?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-text-file-with-delimiter-semicolon-and-header/m-p/721110#M223435</link>
      <description>&lt;P&gt;Thanks for your answer. I just found this example in SAS documentation:&lt;BR /&gt;&lt;BR /&gt;proc import datafile="C:\proyecto_sas_bv\Nombre_cuentas_cualit_1001.txt"&lt;BR /&gt;out=Nombre_cuentas_cualit_1001&lt;BR /&gt;dbms=dlm&lt;BR /&gt;replace;&lt;BR /&gt;dlm=';';&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;But I can not see the error it says:&lt;BR /&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2021 22:19:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-text-file-with-delimiter-semicolon-and-header/m-p/721110#M223435</guid>
      <dc:creator>eduarxj32</dc:creator>
      <dc:date>2021-02-22T22:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a text file with delimiter semicolon and header?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-text-file-with-delimiter-semicolon-and-header/m-p/721112#M223436</link>
      <description>Post the exact log as it indicates where the error is, your code looks correct but it's likely a missing semicolon or an extra one somewhere.</description>
      <pubDate>Mon, 22 Feb 2021 22:22:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-text-file-with-delimiter-semicolon-and-header/m-p/721112#M223436</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-02-22T22:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a text file with delimiter semicolon and header?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-text-file-with-delimiter-semicolon-and-header/m-p/721204#M223491</link>
      <description>&lt;P&gt;Don't waste time with PROC IMPORT when reading text files, in the end you are faster writing the code yourself:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
infile datalines dlm=";" dsd truncover firstobs=2;
input code :$1. description :$10. total;
datalines4;
code;description;total
1;hi;201
2;hey;301
3;good;401
;;;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For your actual file, replace the DATALINES keyword in the INFILE statement with your filename, and remove the DATALINES4; block.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2021 07:55:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-text-file-with-delimiter-semicolon-and-header/m-p/721204#M223491</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-23T07:55:46Z</dc:date>
    </item>
  </channel>
</rss>

