<?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 counting horizontally ..... in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/counting-horizontally/m-p/76901#M22296</link>
    <description>I should get the below output from the given dataset "X" .&lt;BR /&gt;
data x;&lt;BR /&gt;
input id a$ b$ c$ d$ e$ f$ g$;&lt;BR /&gt;
cards;&lt;BR /&gt;
1 B B B C C C P&lt;BR /&gt;
3 B B C C C C P&lt;BR /&gt;
4 C C C C C P P&lt;BR /&gt;
5 B C C P P P P&lt;BR /&gt;
6 P P P P P P P&lt;BR /&gt;
7 C C C C P P P&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
output:&lt;BR /&gt;
&lt;BR /&gt;
id count(B) count(C) count(P)&lt;BR /&gt;
1    3              3            1&lt;BR /&gt;
3    2              4             1&lt;BR /&gt;
4    0              5             2&lt;BR /&gt;
....&lt;BR /&gt;
.&lt;BR /&gt;
.

Message was edited by: Michel_SAS</description>
    <pubDate>Thu, 12 Mar 2009 07:13:54 GMT</pubDate>
    <dc:creator>R_Win</dc:creator>
    <dc:date>2009-03-12T07:13:54Z</dc:date>
    <item>
      <title>counting horizontally .....</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/counting-horizontally/m-p/76901#M22296</link>
      <description>I should get the below output from the given dataset "X" .&lt;BR /&gt;
data x;&lt;BR /&gt;
input id a$ b$ c$ d$ e$ f$ g$;&lt;BR /&gt;
cards;&lt;BR /&gt;
1 B B B C C C P&lt;BR /&gt;
3 B B C C C C P&lt;BR /&gt;
4 C C C C C P P&lt;BR /&gt;
5 B C C P P P P&lt;BR /&gt;
6 P P P P P P P&lt;BR /&gt;
7 C C C C P P P&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
output:&lt;BR /&gt;
&lt;BR /&gt;
id count(B) count(C) count(P)&lt;BR /&gt;
1    3              3            1&lt;BR /&gt;
3    2              4             1&lt;BR /&gt;
4    0              5             2&lt;BR /&gt;
....&lt;BR /&gt;
.&lt;BR /&gt;
.

Message was edited by: Michel_SAS</description>
      <pubDate>Thu, 12 Mar 2009 07:13:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/counting-horizontally/m-p/76901#M22296</guid>
      <dc:creator>R_Win</dc:creator>
      <dc:date>2009-03-12T07:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: counting horizontally .....</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/counting-horizontally/m-p/76902#M22297</link>
      <description>got it&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data y(drop= a--g i);&lt;BR /&gt;
set x;&lt;BR /&gt;
array arr&lt;LI&gt; _character_;&lt;BR /&gt;
bcount=0;Ccount=0;Pcount=0;&lt;BR /&gt;
do i=1 to dim(arr);&lt;BR /&gt;
select (arr&lt;I&gt;);&lt;BR /&gt;
when ("B")  Bcount=Bcount+1;&lt;BR /&gt;
when ("C") Ccount=Ccount+1;&lt;BR /&gt;
when ("P") Pcount=Pcount+1;&lt;BR /&gt;
end;&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;/I&gt;&lt;/LI&gt;</description>
      <pubDate>Thu, 12 Mar 2009 07:38:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/counting-horizontally/m-p/76902#M22297</guid>
      <dc:creator>R_Win</dc:creator>
      <dc:date>2009-03-12T07:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: counting horizontally .....</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/counting-horizontally/m-p/76903#M22298</link>
      <description>data y(drop=x--r i );&lt;BR /&gt;
set x;&lt;BR /&gt;
bounce_string=cat(a,b,c,d,e,f,g);&lt;BR /&gt;
BCount=0;CCount=0;PCount=0;&lt;BR /&gt;
do i=1 to length(bounce_string);&lt;BR /&gt;
select(substr(bounce_string,i,1));&lt;BR /&gt;
when ("b") BCount=Bcount+1;&lt;BR /&gt;
when ("p") PCount=Pcount+1;&lt;BR /&gt;
when ("c") CCount=CCount+1;&lt;BR /&gt;
otherwise;&lt;BR /&gt;
end;&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
run;

Message was edited by: Michel_SAS</description>
      <pubDate>Thu, 12 Mar 2009 10:13:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/counting-horizontally/m-p/76903#M22298</guid>
      <dc:creator>R_Win</dc:creator>
      <dc:date>2009-03-12T10:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: counting horizontally .....</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/counting-horizontally/m-p/76904#M22299</link>
      <description>Try the COUNT function.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data x;&lt;BR /&gt;
   input id a$ b$ c$ d$ e$ f$ g$;&lt;BR /&gt;
   array v&lt;LI&gt; a b c d e f g;&lt;BR /&gt;
   string = cats(of v&lt;/LI&gt;&lt;LI&gt;);&lt;BR /&gt;
   bCount = count(string,'B');&lt;BR /&gt;
   cCount = count(string,'C');&lt;BR /&gt;
   pCount = count(string,'P');&lt;BR /&gt;
   cards;&lt;BR /&gt;
1 B B B C C C P&lt;BR /&gt;
3 B B C C C C P&lt;BR /&gt;
4 C C C C C P P&lt;BR /&gt;
5 B C C P P P P&lt;BR /&gt;
6 P P P P P P P&lt;BR /&gt;
7 C C C C P P P&lt;BR /&gt;
;;;;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]&lt;/LI&gt;</description>
      <pubDate>Thu, 12 Mar 2009 11:28:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/counting-horizontally/m-p/76904#M22299</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2009-03-12T11:28:48Z</dc:date>
    </item>
  </channel>
</rss>

