<?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: Import a text file, with a text. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Import-a-text-file-with-a-text/m-p/355611#M83287</link>
    <description>Haha so many similar and correct answers in a minute. Bet they have all replied (as I did) thinking to be the first &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
    <pubDate>Wed, 03 May 2017 14:04:52 GMT</pubDate>
    <dc:creator>jklaverstijn</dc:creator>
    <dc:date>2017-05-03T14:04:52Z</dc:date>
    <item>
      <title>Import a text file, with a text.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-a-text-file-with-a-text/m-p/355588#M83278</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a problem. So I wanted to do a macro which imports a txt file into sas. The txt contains random words in one line. So basically I want to do is that put them into one column. My method would do it, but it's keep saying ERROR.&lt;/P&gt;&lt;P&gt;The ERROR:&lt;/P&gt;&lt;P&gt;"NOTE: Invalid data for words in line 12 1-4.&lt;BR /&gt;12 down, 5&lt;BR /&gt;words=. _ERROR_=1 _N_=12" and so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or it just doesn't show any words. Just a '.'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;PRE&gt;%macro wordfreq(x);
data test.wrd;
infile "D:\Munka\&amp;amp;x..txt"
DLM=',';
input words;
run;
%mend;

%wordfreq(wrd);

The txt contains:
random, words, coming, up, right, now, here, random, words, here, coming, down, up, word, coming, random, way&lt;/PRE&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;ps.: My main tast is to do a freq macro which group the same words and show the frequency of each ones. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2017 13:44:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-a-text-file-with-a-text/m-p/355588#M83278</guid>
      <dc:creator>Derdavos</dc:creator>
      <dc:date>2017-05-03T13:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: Import a text file, with a text.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-a-text-file-with-a-text/m-p/355602#M83282</link>
      <description>&lt;P&gt;If it's all separated by commas have you tried using a trailing&amp;nbsp;@@?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Input word $&amp;nbsp;@@;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2017 14:00:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-a-text-file-with-a-text/m-p/355602#M83282</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-03T14:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: Import a text file, with a text.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-a-text-file-with-a-text/m-p/355605#M83283</link>
      <description>&lt;P&gt;I think what you want is the&amp;nbsp;@@ modifier on your input statement, as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data want;
infile datalines dsd;
input words $ @@;
datalines;
random, words, coming, up, right, now, here, random, words, here, coming, down, up, word, coming, random, way
;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 May 2017 14:00:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-a-text-file-with-a-text/m-p/355605#M83283</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-05-03T14:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: Import a text file, with a text.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-a-text-file-with-a-text/m-p/355606#M83284</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I'm not entirely use why you need a Macro program to do this. I think all you need to do is change your INPUT statement and use PROC FREQ.&lt;/P&gt;
&lt;P&gt;cynthia&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8686i1AD27219CFE295C5/image-size/original?v=1.0&amp;amp;px=-1" alt="word_freq.png" title="word_freq.png" border="0" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2017 14:01:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-a-text-file-with-a-text/m-p/355606#M83284</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-05-03T14:01:04Z</dc:date>
    </item>
    <item>
      <title>Re: Import a text file, with a text.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-a-text-file-with-a-text/m-p/355607#M83285</link>
      <description>&lt;P&gt;Two things come to mind when looking at your code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) Your input statement defines WORD as numeric. Use a dollar sign to indicate a character.&lt;/P&gt;
&lt;P&gt;2) Your file seems to have multiple valiues for WORD in a single line. Your code however reads just the first word in every line. Use a double trailing at sign to retain the record in the buffer until all words are collected:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename t temp;
data _null_;
file t;
put 'random, words, coming, up, right, now, here, random, words, here, coming, down, up, word, coming, random, way';
run;

%macro wordfreq(x);
data wrd;
infile t DLM=',';
input words $ @@;
run;
%mend;

%wordfreq(wrd);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(I have put your data into a temp file for easier testing)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;- Jan.&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2017 14:02:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-a-text-file-with-a-text/m-p/355607#M83285</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2017-05-03T14:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: Import a text file, with a text.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-a-text-file-with-a-text/m-p/355608#M83286</link>
      <description>&lt;P&gt;Since Cynthia is on here answering questions, I think I'll just get started on my actual job... &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2017 14:02:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-a-text-file-with-a-text/m-p/355608#M83286</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-05-03T14:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: Import a text file, with a text.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-a-text-file-with-a-text/m-p/355611#M83287</link>
      <description>Haha so many similar and correct answers in a minute. Bet they have all replied (as I did) thinking to be the first &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 03 May 2017 14:04:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-a-text-file-with-a-text/m-p/355611#M83287</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2017-05-03T14:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: Import a text file, with a text.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-a-text-file-with-a-text/m-p/357389#M83890</link>
      <description>&lt;P&gt;Thank you all for your answer (sorry for this late reply), almost every answer was correct. Thank you again! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 07:25:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-a-text-file-with-a-text/m-p/357389#M83890</guid>
      <dc:creator>Derdavos</dc:creator>
      <dc:date>2017-05-10T07:25:13Z</dc:date>
    </item>
  </channel>
</rss>

