<?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 stata or xlsx file with massive text fields in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/import-stata-or-xlsx-file-with-massive-text-fields/m-p/457291#M115927</link>
    <description>&lt;P&gt;Hi experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I received a xlsx dataset with some text fields that are pretty massive,&amp;nbsp;for example..&amp;nbsp;brief narratives or diagnosis history from a doctors visit. I can import it to stata 14 without problems, but I can't import the xlsx to SAS with either the proc import, infile or import wizard.&amp;nbsp;Any idea why?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And because SAS does not import Stata 14 files, even if I replace it with the older Stata version 12, it only saves those text fields to lengths of 244.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any advice or SAS code!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Apr 2018 14:02:53 GMT</pubDate>
    <dc:creator>jsmall</dc:creator>
    <dc:date>2018-04-25T14:02:53Z</dc:date>
    <item>
      <title>import stata or xlsx file with massive text fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-stata-or-xlsx-file-with-massive-text-fields/m-p/457291#M115927</link>
      <description>&lt;P&gt;Hi experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I received a xlsx dataset with some text fields that are pretty massive,&amp;nbsp;for example..&amp;nbsp;brief narratives or diagnosis history from a doctors visit. I can import it to stata 14 without problems, but I can't import the xlsx to SAS with either the proc import, infile or import wizard.&amp;nbsp;Any idea why?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And because SAS does not import Stata 14 files, even if I replace it with the older Stata version 12, it only saves those text fields to lengths of 244.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any advice or SAS code!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Apr 2018 14:02:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-stata-or-xlsx-file-with-massive-text-fields/m-p/457291#M115927</guid>
      <dc:creator>jsmall</dc:creator>
      <dc:date>2018-04-25T14:02:53Z</dc:date>
    </item>
    <item>
      <title>Re: import stata or xlsx file with massive text fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-stata-or-xlsx-file-with-massive-text-fields/m-p/457305#M115934</link>
      <description>&lt;P&gt;SAS varaibles have a limit, 2000 characters.&amp;nbsp; I would suggest dropping the data into plain text file format.&amp;nbsp; Then you can read the plain text file character after character and output to strings.&amp;nbsp; I.e.&lt;/P&gt;
&lt;PRE&gt;data want;
  infile "thetextfile.txt";
  length str $2000;
  input a $char1. @@;  /*might need the at's might not */
  if lengthn(cat(str,a)) &amp;gt; 2000 then do;
    output;
    str=a;
  end;
  else str=cat(str,a);
run;&lt;/PRE&gt;
&lt;P&gt;The question is what are you going to do with that data, its pretty much useless for anything programming or stats related.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Apr 2018 14:23:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-stata-or-xlsx-file-with-massive-text-fields/m-p/457305#M115934</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-25T14:23:48Z</dc:date>
    </item>
    <item>
      <title>Re: import stata or xlsx file with massive text fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-stata-or-xlsx-file-with-massive-text-fields/m-p/457329#M115938</link>
      <description>Thanks for your help, but I can't get this to work. When I proc print, the narrative field comes out empty. I tried with or without @@.&lt;BR /&gt;&lt;BR /&gt;My file has 3 variables cid 8. Encid 8. narrative_assess_imp . I tried inputting all the variables, and that didn't work either. I think I'm confused what the a variable is in your code?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Does the following log help at all?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;8473 data want;&lt;BR /&gt;8474 infile "C:\\narrative.csv";&lt;BR /&gt;8475 length narrative_assess_imp $2000;&lt;BR /&gt;8476 input a $char1. ; /*might need the at's might not */&lt;BR /&gt;8477 if lengthn(cat(narrative_assess_imp,a)) &amp;gt; 2000 then do;&lt;BR /&gt;8478 output;&lt;BR /&gt;8479 narrative_assess_imp=a;&lt;BR /&gt;8480 end;&lt;BR /&gt;8481 else narrative_assess_imp=cat(narrative_assess_imp,a);&lt;BR /&gt;8482 run;&lt;BR /&gt;&lt;BR /&gt;NOTE: The infile "C:\narrative.csv" is:&lt;BR /&gt;&lt;BR /&gt;Filename=C:\narrative.csv,&lt;BR /&gt;RECFM=V,LRECL=32767,&lt;BR /&gt;File Size (bytes)=181558671,&lt;BR /&gt;Last Modified=25Apr2018:10:06:11,&lt;BR /&gt;Create Time=25Apr2018:10:06:08&lt;BR /&gt;&lt;BR /&gt;NOTE: 397651 records were read from the infile "C:\narrative.csv".&lt;BR /&gt;The minimum record length was 12.&lt;BR /&gt;The maximum record length was 2061.&lt;BR /&gt;NOTE: The data set WORK.WANT has 397651 observations and 2 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 19.19 seconds&lt;BR /&gt;cpu time 2.01 seconds&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 25 Apr 2018 15:01:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-stata-or-xlsx-file-with-massive-text-fields/m-p/457329#M115938</guid>
      <dc:creator>jsmall</dc:creator>
      <dc:date>2018-04-25T15:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: import stata or xlsx file with massive text fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-stata-or-xlsx-file-with-massive-text-fields/m-p/457339#M115940</link>
      <description>&lt;P&gt;So your file is a csv.&amp;nbsp; Well, that adds more complexity to the whole thing then.&amp;nbsp; Its hard to say when we can't see the file (or an example).&amp;nbsp; My code was presented to run through a text file character by character, read it in, append it to a string variable and if the length is 2000 then output as a row.&amp;nbsp; I.e. cutting the string up into blocks of 2000 characters.&amp;nbsp; Not a good fit for what you now say.&amp;nbsp; I would need to know something about what the file looks like and what you intend to be the output from it as each "cell" in a dataset can only have a maximum of 2000 characters, so you will need to cut it out into blocks of this somehow, but is that data really useful to anyone or any process?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Apr 2018 15:09:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-stata-or-xlsx-file-with-massive-text-fields/m-p/457339#M115940</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-25T15:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: import stata or xlsx file with massive text fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-stata-or-xlsx-file-with-massive-text-fields/m-p/457346#M115945</link>
      <description>&lt;P&gt;Did you use the XLSX engine?&amp;nbsp; It should not have a problem with your file.&amp;nbsp; The limit for a character variable in a SAS dataset is 32K bytes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname in xlsx 'myfile.xlsx';
proc copy inlib=in outlib=work;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Apr 2018 15:14:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-stata-or-xlsx-file-with-massive-text-fields/m-p/457346#M115945</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-04-25T15:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: import stata or xlsx file with massive text fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-stata-or-xlsx-file-with-massive-text-fields/m-p/457360#M115954</link>
      <description>&lt;P&gt;Yeah, I tried exporting the variables i needed to a csv using stata and trying to import it into sas that way. there's 3 variables in the file, 2 unique ids and the character variable which is ultimately a bunch of sentences. I plan to search this text variable for key words for race, marital status, etc..&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does that help at all?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Apr 2018 15:27:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-stata-or-xlsx-file-with-massive-text-fields/m-p/457360#M115954</guid>
      <dc:creator>jsmall</dc:creator>
      <dc:date>2018-04-25T15:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: import stata or xlsx file with massive text fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-stata-or-xlsx-file-with-massive-text-fields/m-p/457362#M115956</link>
      <description>&lt;P&gt;Hi, I'm trying this now, I've never used this code before, so I hope it works, but it seems like SAS is going to time out, it's been churning this whole time. I'll keep you posted. Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Wed, 25 Apr 2018 15:32:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-stata-or-xlsx-file-with-massive-text-fields/m-p/457362#M115956</guid>
      <dc:creator>jsmall</dc:creator>
      <dc:date>2018-04-25T15:32:03Z</dc:date>
    </item>
  </channel>
</rss>

