<?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: counting of words in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/counting-of-words/m-p/277113#M2855</link>
    <description>&lt;P&gt;There can be many ways...below mentioned is counting of blanks by compressing blank.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data new;&lt;BR /&gt;set a;&lt;BR /&gt;word_count=length(name) - length(compress(name)) +1 ;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Tue, 14 Jun 2016 05:02:31 GMT</pubDate>
    <dc:creator>RahulG</dc:creator>
    <dc:date>2016-06-14T05:02:31Z</dc:date>
    <item>
      <title>counting of words</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/counting-of-words/m-p/277109#M2854</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;can you please provise me solution of follwing problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to count no of words from following data with the help of do loop only (do not use COUNTW function ).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;data a;&lt;BR /&gt;input name $ 1-30;&lt;BR /&gt;datalines;&lt;BR /&gt;i am vinayak more&lt;BR /&gt;asif shaikh is my friend&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output should be like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;count&lt;BR /&gt;i am vinayak more &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4&lt;BR /&gt;asif shaikh is my friend &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2016 04:32:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/counting-of-words/m-p/277109#M2854</guid>
      <dc:creator>_sas</dc:creator>
      <dc:date>2016-06-14T04:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: counting of words</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/counting-of-words/m-p/277113#M2855</link>
      <description>&lt;P&gt;There can be many ways...below mentioned is counting of blanks by compressing blank.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data new;&lt;BR /&gt;set a;&lt;BR /&gt;word_count=length(name) - length(compress(name)) +1 ;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2016 05:02:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/counting-of-words/m-p/277113#M2855</guid>
      <dc:creator>RahulG</dc:creator>
      <dc:date>2016-06-14T05:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: counting of words</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/counting-of-words/m-p/277115#M2856</link>
      <description>Thanks rahul.&lt;BR /&gt;can you plz tell me how can i find this count with the help of do loop ?</description>
      <pubDate>Tue, 14 Jun 2016 05:22:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/counting-of-words/m-p/277115#M2856</guid>
      <dc:creator>_sas</dc:creator>
      <dc:date>2016-06-14T05:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: counting of words</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/counting-of-words/m-p/277117#M2857</link>
      <description>&lt;P&gt;Why you post it at IML forum, Another DO LOOP is using CALL PRXNEXT().&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
input name $ 1-30;
datalines;
i am vinayak more
asif shaikh is my friend
;
run;
data want;
 set a;
 i=1;count=0;
 temp=scan(name,i);
 do while(not missing(temp));
  count+1;
  i+1;
  temp=scan(name,i);
 end;
drop i temp;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Jun 2016 05:32:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/counting-of-words/m-p/277117#M2857</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-06-14T05:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: counting of words</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/counting-of-words/m-p/277120#M2858</link>
      <description>&lt;P&gt;The below code would also take care if there are multiple blanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data a;&lt;BR /&gt;input name $ 1-30;&lt;BR /&gt;datalines;&lt;BR /&gt;i &amp;nbsp; am vinayak more&lt;BR /&gt;asif shaikh &amp;nbsp; is my friend&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data new(drop = len c char_val last_char_val);&lt;BR /&gt;length last_char_val $1. ;&lt;BR /&gt;retain last_char_val;&lt;BR /&gt;set a;&lt;BR /&gt;len=length(name);&lt;BR /&gt;c=1;word_count=0;&lt;BR /&gt;do while(c&amp;lt;=len);&lt;BR /&gt;char_val=substr(name,c,1);&lt;BR /&gt;if char_val eq ' ' and last_char_val ne ' ' then word_count +1;&lt;BR /&gt;c+1;&lt;BR /&gt;last_char_val=char_val;&lt;BR /&gt;end;&lt;BR /&gt;word_count +1;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2016 05:42:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/counting-of-words/m-p/277120#M2858</guid>
      <dc:creator>RahulG</dc:creator>
      <dc:date>2016-06-14T05:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: counting of words</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/counting-of-words/m-p/277121#M2859</link>
      <description>&lt;P&gt;OK. I just figure out IML way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
input name $ 1-30;
datalines;
i am vinayak more
asif shaikh is my friend
;
run;
proc iml;
use a;
read all var{name};
close;

count=j(nrow(name),1,0);
do i=1 to nrow(name);
token=substr(name[i],1:length(name[i]),1);
count[i]=sum(token=' ')+1;
end;
print name count;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Jun 2016 05:47:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/counting-of-words/m-p/277121#M2859</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-06-14T05:47:18Z</dc:date>
    </item>
    <item>
      <title>Re: counting of words</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/counting-of-words/m-p/277160#M2860</link>
      <description>&lt;P&gt;And why "don't use countw"? &amp;nbsp;I would think that a function specifically designed and written for the purpose would be better than any other solution?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2016 08:42:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/counting-of-words/m-p/277160#M2860</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-06-14T08:42:42Z</dc:date>
    </item>
  </channel>
</rss>

