<?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: count question in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/count-question/m-p/68404#M19590</link>
    <description>In case that the N_tot value in row one is not always the one containing the maximum then the following would be an option:&lt;BR /&gt;
&lt;BR /&gt;
data have;&lt;BR /&gt;
input N N_tot T_tot;&lt;BR /&gt;
datalines;&lt;BR /&gt;
0 68243 47739&lt;BR /&gt;
1 376 182&lt;BR /&gt;
2 204 144&lt;BR /&gt;
3 427 248&lt;BR /&gt;
4 217 150&lt;BR /&gt;
5 575 326&lt;BR /&gt;
6 87 62&lt;BR /&gt;
7 393 247&lt;BR /&gt;
8 1096 710&lt;BR /&gt;
9 453 296&lt;BR /&gt;
;&lt;BR /&gt;
proc sql;&lt;BR /&gt;
/*create table want as*/&lt;BR /&gt;
select *,max(n_tot) as Count&lt;BR /&gt;
from have;&lt;BR /&gt;
quit;</description>
    <pubDate>Mon, 15 Mar 2010 23:58:20 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2010-03-15T23:58:20Z</dc:date>
    <item>
      <title>count question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/count-question/m-p/68402#M19588</link>
      <description>I have done this function before but am frustrated that I can not remember how!&lt;BR /&gt;
&lt;BR /&gt;
so I have a table with 68k observations.  I would like to create a new column in my dataset with this total number.  I do not wish to hardcode this number because it may change.&lt;BR /&gt;
&lt;BR /&gt;
currently my dataset is:&lt;BR /&gt;
&lt;BR /&gt;
N     N_tot	         T_tot&lt;BR /&gt;
0	68243	47739&lt;BR /&gt;
1	376	         182&lt;BR /&gt;
2	204	         144&lt;BR /&gt;
3	427	         248&lt;BR /&gt;
4	217	         150&lt;BR /&gt;
5	575	         326&lt;BR /&gt;
6	87	         62&lt;BR /&gt;
7	393	         247&lt;BR /&gt;
8	1096	         710&lt;BR /&gt;
9	453	         296&lt;BR /&gt;
&lt;BR /&gt;
I would like to appear as &lt;BR /&gt;
&lt;BR /&gt;
N     N_tot	         T_tot       Count&lt;BR /&gt;
0	68243	47739       68243&lt;BR /&gt;
1	376	         182          68243&lt;BR /&gt;
2	204	         144          68243          &lt;BR /&gt;
3	427	         248          68243&lt;BR /&gt;
4	217	         150          68243&lt;BR /&gt;
5	575	         326          68243&lt;BR /&gt;
6	87	         62            68243&lt;BR /&gt;
7	393	         247          68243&lt;BR /&gt;
8	1096	         710          68243&lt;BR /&gt;
9	453	         296          68243&lt;BR /&gt;
&lt;BR /&gt;
I would really appreciate any assistance.</description>
      <pubDate>Mon, 15 Mar 2010 20:35:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/count-question/m-p/68402#M19588</guid>
      <dc:creator>Hart</dc:creator>
      <dc:date>2010-03-15T20:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: count question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/count-question/m-p/68403#M19589</link>
      <description>Sounds like you are looking for the RETAIN statement</description>
      <pubDate>Mon, 15 Mar 2010 20:42:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/count-question/m-p/68403#M19589</guid>
      <dc:creator>RickM</dc:creator>
      <dc:date>2010-03-15T20:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: count question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/count-question/m-p/68404#M19590</link>
      <description>In case that the N_tot value in row one is not always the one containing the maximum then the following would be an option:&lt;BR /&gt;
&lt;BR /&gt;
data have;&lt;BR /&gt;
input N N_tot T_tot;&lt;BR /&gt;
datalines;&lt;BR /&gt;
0 68243 47739&lt;BR /&gt;
1 376 182&lt;BR /&gt;
2 204 144&lt;BR /&gt;
3 427 248&lt;BR /&gt;
4 217 150&lt;BR /&gt;
5 575 326&lt;BR /&gt;
6 87 62&lt;BR /&gt;
7 393 247&lt;BR /&gt;
8 1096 710&lt;BR /&gt;
9 453 296&lt;BR /&gt;
;&lt;BR /&gt;
proc sql;&lt;BR /&gt;
/*create table want as*/&lt;BR /&gt;
select *,max(n_tot) as Count&lt;BR /&gt;
from have;&lt;BR /&gt;
quit;</description>
      <pubDate>Mon, 15 Mar 2010 23:58:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/count-question/m-p/68404#M19590</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-03-15T23:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: count question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/count-question/m-p/68405#M19591</link>
      <description>Maybe:&lt;BR /&gt;
&lt;BR /&gt;
data T;&lt;BR /&gt;
  set T nobs=NOBS;    *read nb of obs;&lt;BR /&gt;
  COUNT=NOBS;        *save nb of obs;&lt;BR /&gt;
 run;</description>
      <pubDate>Thu, 18 Mar 2010 22:36:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/count-question/m-p/68405#M19591</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2010-03-18T22:36:41Z</dc:date>
    </item>
  </channel>
</rss>

