<?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 one large text file, exceeds max characters allowed per cell in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-one-large-text-file-exceeds-max-characters-allowed-per/m-p/938534#M368638</link>
    <description>&lt;P&gt;If by "import" you mean Proc Import or any of the widgets that call proc import then your data is inappropriate for use. Proc Import is intended for structured data in pretty regular terms.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A data step can do what you want, I think:&lt;/P&gt;
&lt;PRE&gt;data read;
   infile "some text file name.txt" lrecl=320000 flowover;
   input (v1 - v10)  ($32000.);
run;&lt;/PRE&gt;
&lt;P&gt;the LRECL, logical record length, would attempt to default to something much to short. Flowover on the infile should handle any line break characters. I picked a combination of LRECL and variables lengths so they easily complement each other to evenly divide 10 variables into the record length.&lt;/P&gt;
&lt;P&gt;The input with () groups things to repeat the use. So this reads the first 32,000 characters into V1, the second 32,000 into V2 etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: some forms of apparently "unstructured" text, such as report files, actually have a complex structure, also not suitable for Proc Import, but can be read in a meaningful way.&lt;/P&gt;</description>
    <pubDate>Wed, 07 Aug 2024 14:30:25 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-08-07T14:30:25Z</dc:date>
    <item>
      <title>Importing one large text file, exceeds max characters allowed per cell</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-one-large-text-file-exceeds-max-characters-allowed-per/m-p/938526#M368636</link>
      <description>&lt;P&gt;I am importing an unstructured text data file that exceeds the allowed limit per cell for SAS.&lt;/P&gt;&lt;P&gt;After fudging around a bit, I have been able to import&amp;nbsp;&lt;EM&gt;some&lt;/EM&gt; of the data, but it is not ideal situation and doesn't pull in the entire file it seems.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a while, perhaps through the infile statement, that I can say, if the string exceeds 32000 string characters, start variable2 and continue to drop the data into successive variables until all text is stored?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;example:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;data file&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;158,000 characters&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;var1&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;var2&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;var3&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;var4&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;tons of characters -&lt;/STRONG&gt; aopndvikadfngnf;afngaogkma'psvdmax;clvkdasf&lt;/P&gt;&lt;P&gt;gh, q-vw35iv,a -s8eri0t a,zs[0ro86ybuqi4,]-=l "*SIDgkj'pac';ew4l6kgvjw-4n5c&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;picksup where var1 left off &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;- aonwerdvp maq9nyrgha;oriltluakce;sort8ryacfusfe&lt;/P&gt;&lt;P&gt;/;.5gqa7w4pj5ca.seurjcioanuyrec&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;and so on&lt;/TD&gt;&lt;TD&gt;and so forth... till the end of the text file&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 13:57:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-one-large-text-file-exceeds-max-characters-allowed-per/m-p/938526#M368636</guid>
      <dc:creator>therealgtc3</dc:creator>
      <dc:date>2024-08-07T13:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: Importing one large text file, exceeds max characters allowed per cell</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-one-large-text-file-exceeds-max-characters-allowed-per/m-p/938533#M368637</link>
      <description>&lt;P&gt;Example 5 in the following SAS Global Forum paper describes how you can split your variable that is longer than 32K into more than one variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings11/256-2011.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings11/256-2011.pdf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 14:29:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-one-large-text-file-exceeds-max-characters-allowed-per/m-p/938533#M368637</guid>
      <dc:creator>Michael_TH</dc:creator>
      <dc:date>2024-08-07T14:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: Importing one large text file, exceeds max characters allowed per cell</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-one-large-text-file-exceeds-max-characters-allowed-per/m-p/938534#M368638</link>
      <description>&lt;P&gt;If by "import" you mean Proc Import or any of the widgets that call proc import then your data is inappropriate for use. Proc Import is intended for structured data in pretty regular terms.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A data step can do what you want, I think:&lt;/P&gt;
&lt;PRE&gt;data read;
   infile "some text file name.txt" lrecl=320000 flowover;
   input (v1 - v10)  ($32000.);
run;&lt;/PRE&gt;
&lt;P&gt;the LRECL, logical record length, would attempt to default to something much to short. Flowover on the infile should handle any line break characters. I picked a combination of LRECL and variables lengths so they easily complement each other to evenly divide 10 variables into the record length.&lt;/P&gt;
&lt;P&gt;The input with () groups things to repeat the use. So this reads the first 32,000 characters into V1, the second 32,000 into V2 etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: some forms of apparently "unstructured" text, such as report files, actually have a complex structure, also not suitable for Proc Import, but can be read in a meaningful way.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 14:30:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-one-large-text-file-exceeds-max-characters-allowed-per/m-p/938534#M368638</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-08-07T14:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: Importing one large text file, exceeds max characters allowed per cell</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-one-large-text-file-exceeds-max-characters-allowed-per/m-p/938593#M368653</link>
      <description>&lt;P&gt;If it is unstructured then how to know where the "cells" start and end?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 19:53:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-one-large-text-file-exceeds-max-characters-allowed-per/m-p/938593#M368653</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-08-07T19:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: Importing one large text file, exceeds max characters allowed per cell</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-one-large-text-file-exceeds-max-characters-allowed-per/m-p/938600#M368655</link>
      <description>&lt;P&gt;Use the $CHAR informat instead to preserve leading spaces at the boundary points.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 20:20:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-one-large-text-file-exceeds-max-characters-allowed-per/m-p/938600#M368655</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-08-07T20:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: Importing one large text file, exceeds max characters allowed per cell</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-one-large-text-file-exceeds-max-characters-allowed-per/m-p/938602#M368656</link>
      <description>&lt;P&gt;If the goal is to read lines of text into multiple shorter character variables then something like this should work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's use 10 as the maximum length for one value so our example can be small.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First let's make a sample file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options parmcards=txt;
filename txt temp;
parmcards;
one,two,three
1,2,3
1234567890,12345678901,123456789012
1234567890123456789012345678901234567890
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now let's read it in.&amp;nbsp; We can use the LRECL= to tell SAS that the lines are longer than the default 32K bytes.&amp;nbsp; Note there is a limit to how large LRECL can be, but it is probably more than 1 million on most installations of SAS.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We can use the LENGTH= and COLUMN= option to determine when we have reached the end of the line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So let's just make one observation per each 10 bytes read.&amp;nbsp; We can add some additional variables to indicate where the 10 bytes came from.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tall ;
  infile txt truncover length=ll column=cc lrecl=1000000 ;
  length row col 8 value $10;
  row+1;
  do col=1 by 1 until(cc&amp;gt;ll);
    input value $char10. @ ;
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;Obs    row    col    value

  1     1      1     one,two,th
  2     1      2     ree
  3     2      1     1,2,3
  4     3      1     1234567890
  5     3      2     ,123456789
  6     3      3     01,1234567
  7     3      4     89012
  8     4      1     1234567890
  9     4      2     1234567890
 10     4      3     1234567890
 11     4      4     1234567890
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 20:29:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-one-large-text-file-exceeds-max-characters-allowed-per/m-p/938602#M368656</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-08-07T20:29:11Z</dc:date>
    </item>
  </channel>
</rss>

