<?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: I have data set need to count column b values how many times it repeated in column a? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/I-have-data-set-need-to-count-column-b-values-how-many-times-it/m-p/463562#M118115</link>
    <description>&lt;P&gt;Are you after this????&lt;/P&gt;&lt;P&gt;Your wrote --"&lt;SPAN&gt;&amp;nbsp;I need like B column value need to search for &lt;STRONG&gt;same and less&lt;/STRONG&gt; then to A column value."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Require output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;b c&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 0&lt;/P&gt;&lt;P&gt;2 4&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;3 1 /*this should be 7?*/&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
input a b;
cards;
0.1 1
0.2 2
1   3
1   4
2   5
3   6
4	.
4	.
;
run;
proc sql;
create table want as
select a.b,sum(b.a&amp;lt;=a.b) as count
from a a,a b
where  a.b ne .
group by a.b;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 19 May 2018 19:12:05 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-05-19T19:12:05Z</dc:date>
    <item>
      <title>I have data set need to count column b values how many times it repeated in column a?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-have-data-set-need-to-count-column-b-values-how-many-times-it/m-p/463504#M118094</link>
      <description>&lt;PRE&gt;&lt;BR /&gt;data a;
input a b;
cards;
0.1 1
0.2 2
1   3
1   4
2   5
3   6
4
4
;
run;

o/p:

  b c
  1 4
  2 1
  3 1
  4 2
  5 0
  6 0


&lt;/PRE&gt;&lt;P&gt;I have data need to count b column values with in a column how many times it repeated and b columns values must be equal to a as well as it should be less then of it..&lt;/P&gt;</description>
      <pubDate>Sat, 19 May 2018 12:38:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-have-data-set-need-to-count-column-b-values-how-many-times-it/m-p/463504#M118094</guid>
      <dc:creator>rajeshalwayswel</dc:creator>
      <dc:date>2018-05-19T12:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: I have data set need to count column b values how many times it repeated in column a?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-have-data-set-need-to-count-column-b-values-how-many-times-it/m-p/463512#M118097</link>
      <description>&lt;P&gt;If you don't have very large data then you can perform a Cartesian product and write a logic to count.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
infile cards missover;
input a b;
cards;
0.1 1
0.2 2
1   3
1   4
2   5
3   6
4
4
;
run;

proc sql;
create table many as
select t1.b,t2.a
from a as t1,a as t2
where t1.b is not null
order by t1.b
;
quit;
data want(drop=a);
retain count;
set many;
by b;
if first.b then count=0;
If b-1&amp;lt;a&amp;lt;=b then count+1;
if last.b;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If your data is large I suggest Hash table method.&lt;/P&gt;</description>
      <pubDate>Sat, 19 May 2018 12:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-have-data-set-need-to-count-column-b-values-how-many-times-it/m-p/463512#M118097</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-05-19T12:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: I have data set need to count column b values how many times it repeated in column a?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-have-data-set-need-to-count-column-b-values-how-many-times-it/m-p/463528#M118104</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data a;
input a b;
cards;
0.1 1
0.2 2
1   3
1   4
2   5
3   6
4
4
;
run;

proc sql;
select a.b,sum(a.b=b.a) as count
 from a as a,a as b
 where a.b is not missing
  group by a.b;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 May 2018 13:50:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-have-data-set-need-to-count-column-b-values-how-many-times-it/m-p/463528#M118104</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-05-19T13:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: I have data set need to count column b values how many times it repeated in column a?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-have-data-set-need-to-count-column-b-values-how-many-times-it/m-p/463545#M118108</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 
data a;
input a b;
cards;
0.1 1
0.2 2
1   3
1   4
2   5
3   6
4	.
4	.
;
run;
proc sql;
create table want as
select a.b,coalesce(c,0) as count
from a a left join (select a,count(a) as c from a group by a) b
on a.b=b.a
where a.b ne .;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 May 2018 17:09:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-have-data-set-need-to-count-column-b-values-how-many-times-it/m-p/463545#M118108</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-19T17:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: I have data set need to count column b values how many times it repeated in column a?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-have-data-set-need-to-count-column-b-values-how-many-times-it/m-p/463559#M118114</link>
      <description>&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;0.2556%&lt;/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&gt;&lt;TD&gt;1.5982%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0.3508%&lt;/TD&gt;&lt;TD&gt;1.6919%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0.3513%&lt;/TD&gt;&lt;TD&gt;1.7855%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0.3526%&lt;/TD&gt;&lt;TD&gt;1.8791%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0.3527%&lt;/TD&gt;&lt;TD&gt;1.9727%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0.3536%&lt;/TD&gt;&lt;TD&gt;2.0663%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0.3545%&lt;/TD&gt;&lt;TD&gt;2.1600%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0.3632%&lt;/TD&gt;&lt;TD&gt;2.2536%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0.3706%&lt;/TD&gt;&lt;TD&gt;2.3472%&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;some more clear on want I want thanks alot everyone ..but I need like B column value need to search for same and less then to A column value.. if it taken a count from A column it doesn't repeat count when it taken a new value in column B....example&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm showing how it on small data to make clear...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;b&lt;/P&gt;&lt;P&gt;1.1&amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;1.2&amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;BR /&gt;1.3&amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;2.1&lt;/P&gt;&lt;P&gt;2.2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Require output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;b c&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 0&lt;/P&gt;&lt;P&gt;2 4&lt;/P&gt;&lt;P&gt;3 1&lt;/P&gt;</description>
      <pubDate>Sat, 19 May 2018 18:29:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-have-data-set-need-to-count-column-b-values-how-many-times-it/m-p/463559#M118114</guid>
      <dc:creator>rajeshalwayswel</dc:creator>
      <dc:date>2018-05-19T18:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: I have data set need to count column b values how many times it repeated in column a?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-have-data-set-need-to-count-column-b-values-how-many-times-it/m-p/463562#M118115</link>
      <description>&lt;P&gt;Are you after this????&lt;/P&gt;&lt;P&gt;Your wrote --"&lt;SPAN&gt;&amp;nbsp;I need like B column value need to search for &lt;STRONG&gt;same and less&lt;/STRONG&gt; then to A column value."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Require output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;b c&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 0&lt;/P&gt;&lt;P&gt;2 4&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;3 1 /*this should be 7?*/&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
input a b;
cards;
0.1 1
0.2 2
1   3
1   4
2   5
3   6
4	.
4	.
;
run;
proc sql;
create table want as
select a.b,sum(b.a&amp;lt;=a.b) as count
from a a,a b
where  a.b ne .
group by a.b;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 19 May 2018 19:12:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-have-data-set-need-to-count-column-b-values-how-many-times-it/m-p/463562#M118115</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-19T19:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: I have data set need to count column b values how many times it repeated in column a?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-have-data-set-need-to-count-column-b-values-how-many-times-it/m-p/463599#M118134</link>
      <description>&lt;P&gt;In the below which you written code the count gives as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;b&amp;nbsp; count&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;4&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp;5&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp;6&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp;8&lt;/P&gt;&lt;P&gt;5&amp;nbsp; &amp;nbsp; &amp;nbsp; 8&lt;/P&gt;&lt;P&gt;6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;b&amp;nbsp; count&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;4&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;&lt;P&gt;5&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;&lt;P&gt;6&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this way needed ... if a value is counted when it less then or equal to.. it should not repeat count again....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 20 May 2018 03:39:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-have-data-set-need-to-count-column-b-values-how-many-times-it/m-p/463599#M118134</guid>
      <dc:creator>rajeshalwayswel</dc:creator>
      <dc:date>2018-05-20T03:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: I have data set need to count column b values how many times it repeated in column a?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-have-data-set-need-to-count-column-b-values-how-many-times-it/m-p/463604#M118137</link>
      <description>&lt;P&gt;Since both columns a and b are sorted, you can take advantage of that fact as below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
infile datalines missover;
input a b;
cards;
0.1 1
0.2 2
1   3
1   4
2   5
3   6
4
4
run;

data want ;
  do c=0 by 1 until (inb);
    set a (keep=a rename=(a=b) in=ina)
        a (keep=b where=(b^=.) in=inb);
    by b;
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 20 May 2018 04:41:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-have-data-set-need-to-count-column-b-values-how-many-times-it/m-p/463604#M118137</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-05-20T04:41:49Z</dc:date>
    </item>
    <item>
      <title>Re: I have data set need to count column b values how many times it repeated in column a?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-have-data-set-need-to-count-column-b-values-how-many-times-it/m-p/463621#M118141</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data a;
input _a b;
a=ceil(_a);
cards;
0.1 1
0.2 2
1   3
1   4
2   5
3   6
4
4
;
run;

proc sql;
select a.b,sum(a.b=b.a) as count
 from a as a,a as b
 where a.b is not missing
  group by a.b;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 20 May 2018 10:14:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-have-data-set-need-to-count-column-b-values-how-many-times-it/m-p/463621#M118141</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-05-20T10:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: I have data set need to count column b values how many times it repeated in column a?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-have-data-set-need-to-count-column-b-values-how-many-times-it/m-p/463641#M118146</link>
      <description>&lt;P&gt;0.00256 0.00288&lt;BR /&gt;0.00256 0.00381&lt;BR /&gt;0.00256 0.00475&lt;BR /&gt;0.00267 0.00568&lt;BR /&gt;0.00270 0.00662&lt;BR /&gt;0.00288 0.00756&lt;BR /&gt;0.00288 0.00849&lt;BR /&gt;0.00314 0.00943&lt;BR /&gt;0.00320 0.01037&lt;BR /&gt;0.00320 0.01130&lt;BR /&gt;0.00321 0.01224&lt;BR /&gt;0.00323 0.01317&lt;BR /&gt;0.00326 0.01411&lt;BR /&gt;0.00332 0.01505&lt;BR /&gt;0.00345 0.01598&lt;BR /&gt;0.00351 0.01692&lt;BR /&gt;0.00351 0.01785&lt;BR /&gt;0.00353 0.01879&lt;BR /&gt;0.00353 0.01973&lt;BR /&gt;0.00354 0.02066&lt;BR /&gt;0.00354 0.02160&lt;BR /&gt;0.00363 0.02254&lt;BR /&gt;0.00371 0.02347&lt;BR /&gt;0.00378 0.02441&lt;BR /&gt;0.00380 0.02534&lt;BR /&gt;0.00383 0.02628&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks everyone I have applied above code from the following data but count not getting.. can some one check&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Required output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;count&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;6 ---less then&amp;nbsp;&lt;SPAN&gt;or equal to&lt;/SPAN&gt; 0.00288&lt;/P&gt;&lt;P&gt;18----less then or equal to&amp;nbsp;0.00381&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and so on.....&lt;/P&gt;</description>
      <pubDate>Sun, 20 May 2018 16:15:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-have-data-set-need-to-count-column-b-values-how-many-times-it/m-p/463641#M118146</guid>
      <dc:creator>rajeshalwayswel</dc:creator>
      <dc:date>2018-05-20T16:15:12Z</dc:date>
    </item>
  </channel>
</rss>

