<?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 Import a TXT file with data split by a symbol in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Import-a-TXT-file-with-data-split-by-a-symbol/m-p/812092#M320392</link>
    <description>&lt;P&gt;Question 1:&lt;/P&gt;&lt;P&gt;I have an attached 'try' txt file, which is split by the symbol |. As a rookie, I want to import it nicely into the SAS but not sure how to do it.&lt;/P&gt;&lt;P&gt;Each row should have 21 columns. Hence, some rows may have missing values in some columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Question 2:&lt;/P&gt;&lt;P&gt;After I import the txt file successfully, how do I add a header, say for 21 columns, to this new SAS data? The header I wanna add is also attached here with the name "header".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much.&lt;/P&gt;</description>
    <pubDate>Mon, 09 May 2022 08:59:12 GMT</pubDate>
    <dc:creator>Jarvin99</dc:creator>
    <dc:date>2022-05-09T08:59:12Z</dc:date>
    <item>
      <title>Import a TXT file with data split by a symbol</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-a-TXT-file-with-data-split-by-a-symbol/m-p/812092#M320392</link>
      <description>&lt;P&gt;Question 1:&lt;/P&gt;&lt;P&gt;I have an attached 'try' txt file, which is split by the symbol |. As a rookie, I want to import it nicely into the SAS but not sure how to do it.&lt;/P&gt;&lt;P&gt;Each row should have 21 columns. Hence, some rows may have missing values in some columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Question 2:&lt;/P&gt;&lt;P&gt;After I import the txt file successfully, how do I add a header, say for 21 columns, to this new SAS data? The header I wanna add is also attached here with the name "header".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much.&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2022 08:59:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-a-TXT-file-with-data-split-by-a-symbol/m-p/812092#M320392</guid>
      <dc:creator>Jarvin99</dc:creator>
      <dc:date>2022-05-09T08:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: Import a TXT file with data split by a symbol</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-a-TXT-file-with-data-split-by-a-symbol/m-p/812102#M320397</link>
      <description>&lt;P&gt;Use the header line to write your code, and use informats according to the data.&lt;/P&gt;
&lt;P&gt;But, in a professional environment, you should accept files only with proper documentation, so you do not have to make guesses about variable attributes.&lt;/P&gt;
&lt;P&gt;Anyway, this seems to read your file correctly:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
infile "~/try.txt" dlm="|" dsd truncover;
input
  CMTE_ID :$10.
  AMNDT_IND :$1.
  RPT_TP :$2.
  TRANSACTION_PGI :$5.
  IMAGE_NUM :$20.
  TRANSACTION_TP :$3.
  ENTITY_TP :$3.
  NAME :$50.
  CITY :$50.
  STATE :$2.
  ZIP_CODE :$10.
  EMPLOYER :$50.
  OCCUPATION :$30.
  TRANSACTION_DT :mmddyy8.
  TRANSACTION_AMT
  OTHER_ID :$8.
  TRAN_ID :$20.
  FILE_NUM :$8.
  MEMO_CD :$1.
  MEMO_TEXT :$100.
  SUB_ID :$20.
;
format TRANSACTION_DT yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 May 2022 09:32:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-a-TXT-file-with-data-split-by-a-symbol/m-p/812102#M320397</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-05-09T09:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: Import a TXT file with data split by a symbol</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-a-TXT-file-with-data-split-by-a-symbol/m-p/812108#M320400</link>
      <description>&lt;P&gt;Thank you for your reminder. Here is a brief manual from the database. I have changed most of the character formats, but I am not sure how to change the numeric format, i.e., TRANSACTION_AMT from its default length of 8 to 14 with 2 decimals behind.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know it may be simple but thanks for any help given.&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2022 10:19:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-a-TXT-file-with-data-split-by-a-symbol/m-p/812108#M320400</guid>
      <dc:creator>Jarvin99</dc:creator>
      <dc:date>2022-05-09T10:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: Import a TXT file with data split by a symbol</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-a-TXT-file-with-data-split-by-a-symbol/m-p/812150#M320415</link>
      <description>&lt;P&gt;Note Length and Format are not the same, you really don't want to mess with the length of numeric variables&lt;BR /&gt;see&amp;nbsp;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/hostwin/p1480xrxkbc9lln1liks4bxj3rii.htm" target="_self"&gt;Length and Precision of Variables&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;A format is how SAS displays data&lt;BR /&gt;see&amp;nbsp;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/n11m54nggvjybhn1w2a8mbczw04q.htm" target="_self"&gt;About Formats&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2022 12:41:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-a-TXT-file-with-data-split-by-a-symbol/m-p/812150#M320415</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2022-05-09T12:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: Import a TXT file with data split by a symbol</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-a-TXT-file-with-data-split-by-a-symbol/m-p/812170#M320424</link>
      <description>&lt;P&gt;You do not want to change the&amp;nbsp;&lt;EM&gt;length&lt;/EM&gt; of a numeric variable, as that concerns the number of bytes used to store the numbers. What you want to change is the&amp;nbsp;&lt;EM&gt;display format&lt;/EM&gt; for the numeric values.&lt;/P&gt;
&lt;P&gt;To reliably display up to 14 digits plus 2 fractional digits, use a format of 18.2.&lt;/P&gt;
&lt;P&gt;18 = 14 + 1 (dot) + 1 (sign) + 2 (fractional digits)&lt;/P&gt;
&lt;P&gt;In the code I gave you, extend the FORMAT statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format
  TRANSACTION_DT yymmdd10.
  TRANSACTION_AMT 18.2
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that a number with more than 15 overall decimal digits will have imprecisions in the last digits, because of the limits of 8-byte real storage.&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2022 14:05:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-a-TXT-file-with-data-split-by-a-symbol/m-p/812170#M320424</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-05-09T14:05:37Z</dc:date>
    </item>
  </channel>
</rss>

