<?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: how to find count of the following ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-count-of-the-following/m-p/465276#M118673</link>
    <description>&lt;P&gt;Sorry, It not efficient code. I have lot of records. Any more suggestions.&lt;/P&gt;</description>
    <pubDate>Sat, 26 May 2018 17:36:39 GMT</pubDate>
    <dc:creator>rajeshalwayswel</dc:creator>
    <dc:date>2018-05-26T17:36:39Z</dc:date>
    <item>
      <title>how to find count of the following ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-count-of-the-following/m-p/463802#M118215</link>
      <description>&lt;DIV class="lia-quilt-row lia-quilt-row-forum-message-main"&gt;&lt;DIV class="lia-quilt-column lia-quilt-column-20 lia-quilt-column-right lia-quilt-column-main-right"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-right"&gt;&lt;DIV class="lia-message-body lia-component-body"&gt;&lt;DIV class="lia-message-body-content"&gt;&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;&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;&lt;SPAN&gt;&amp;nbsp;&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;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="lia-quilt-row lia-quilt-row-forum-message-footer"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 21 May 2018 15:55:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-count-of-the-following/m-p/463802#M118215</guid>
      <dc:creator>rajeshalwayswel</dc:creator>
      <dc:date>2018-05-21T15:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: how to find count of the following ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-count-of-the-following/m-p/463816#M118219</link>
      <description>&lt;P&gt;I am assunming every numer will&amp;nbsp; be a value in its own observation and we'll call the variable " val". Than proc format is your friend like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value ranges
   0-0.00288='less than 0.00288'
   0.00288-&amp;lt;0.00381='less than 0.00381'
   other='other ranges can be added';
run;
proc freq data=have;
   table val;
   format val ranges.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;-- Jan&lt;/P&gt;</description>
      <pubDate>Mon, 21 May 2018 16:26:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-count-of-the-following/m-p/463816#M118219</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2018-05-21T16:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to find count of the following ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-count-of-the-following/m-p/463836#M118223</link>
      <description>&lt;P&gt;This thread looks like a duplicate or extension of&amp;nbsp;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/I-have-data-set-need-to-count-column-b-values-how-many-times-it/m-p/463641#M118146" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/I-have-data-set-need-to-count-column-b-values-how-many-times-it/m-p/463641#M118146&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used the sample you gave in that thread as floats gives me enormous eyestrain. If you can follow this code, you should be able to test on any sample:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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;


data want;
if _n_=1 then do;
if 0 then set a(keep=a);
 dcl hash H (dataset:'a(keep=a)',multidata:'y') ;
   h.definekey  ('a') ;
   h.definedata ('a') ;
    h.definedone () ;
dcl hash H1 (multidata:'y') ;
   h1.definekey  ('a') ;
   h1.definedone () ;
 dcl hiter i('h');
end;
set a(keep=b);
array t(100);/*arbitrary subscript for small sample, make it larger*/
call missing(of t(*));
where not missing(b);
count=0;
rc = i.first();
do _n_=1 by 1 while (rc = 0);
if h.check(key:b)=0 and ((a&amp;lt;=b and a  in t) or (a&amp;lt;=b and h1.check() ne 0))  then count+1;
h1.add();
t(_n_)=a;
rc = i.next();
end;
drop t: a rc;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 May 2018 17:54:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-count-of-the-following/m-p/463836#M118223</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-21T17:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to find count of the following ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-count-of-the-following/m-p/465276#M118673</link>
      <description>&lt;P&gt;Sorry, It not efficient code. I have lot of records. Any more suggestions.&lt;/P&gt;</description>
      <pubDate>Sat, 26 May 2018 17:36:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-count-of-the-following/m-p/465276#M118673</guid>
      <dc:creator>rajeshalwayswel</dc:creator>
      <dc:date>2018-05-26T17:36:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to find count of the following ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-count-of-the-following/m-p/465292#M118675</link>
      <description>&lt;P&gt;It appears that both of your columns are in ascending order.&amp;nbsp; And you want column B to form boundaries for tabulating column A, correct?&amp;nbsp;&amp;nbsp;If so then you can interleave records sorted on the values in both a and b, keeping a count of records using A.&amp;nbsp; Every time the value-in-hand comes from column B, subtract the prior count of A from the current count, and output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This program uses the DIF functions (DIF(x)=x-lag(x)).&amp;nbsp; Since the first DIF value will be missing, I use the expression&lt;/P&gt;
&lt;P&gt;&amp;nbsp; FREQ=min(counta,dif(counta)); so that the first FREQ is just a count, while subsequent FREQs are differences in counts:&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;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input a b;
datalines;
0.00256 0.00288
0.00256 0.00381
0.00256 0.00475
0.00267 0.00568
0.00270 0.00662
0.00288 0.00756
0.00288 0.00849
0.00314 0.00943
0.00320 0.01037
0.00320 0.01130
0.00321 0.01224
0.00323 0.01317
0.00326 0.01411
0.00332 0.01505
0.00345 0.01598
0.00351 0.01692
0.00351 0.01785
0.00353 0.01879
0.00353 0.01973
0.00354 0.02066
0.00354 0.02160
0.00363 0.02254
0.00371 0.02347
0.00378 0.02441
0.00380 0.02534
0.00383 0.02628
run;

data want (keep=a freq);
  set have (keep=a in=incolumna)
      have (keep=b rename=(b=a) in=boundary);
  by a;

  counta+incolumna;
  if boundary;
  freq=min(counta,dif(counta));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your data are not sorted as I suggested, you could split the dataset into two datasets (one with column A values, one with column B values), sort each, and interleave them as above.&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>Sat, 26 May 2018 23:41:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-count-of-the-following/m-p/465292#M118675</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-05-26T23:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to find count of the following ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-count-of-the-following/m-p/465316#M118682</link>
      <description>&lt;P&gt;Thanks alot.. I have being try this for two weeks thanks alot.. It really helpful me...&lt;/P&gt;</description>
      <pubDate>Sun, 27 May 2018 06:49:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-count-of-the-following/m-p/465316#M118682</guid>
      <dc:creator>rajeshalwayswel</dc:creator>
      <dc:date>2018-05-27T06:49:28Z</dc:date>
    </item>
  </channel>
</rss>

