<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/count/m-p/315892#M68953</link>
    <description>&lt;P&gt;Determine the number of obs per studid in an intermediate step and then merge with the original dataset.&lt;/P&gt;
&lt;P&gt;Note the use of the keep= option.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input studid marks;
cards;
1 24
1 24
1 24
2 24
2 24
3 24
;
run;

data int (keep=studid);
set have;
by studid;
if first.studid
then newvar = 1;
else newvar + 1;
if last.studid and newvar &amp;gt; 1;
run;

data want;
merge
  have
  int (in=a)
;
by studid;
if a and (first.studid or last.studid);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 01 Dec 2016 11:21:31 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-12-01T11:21:31Z</dc:date>
    <item>
      <title>count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count/m-p/315888#M68950</link>
      <description>&lt;P&gt;Create a dataset to genrate the count of the number of student in a STUD dataset and also display records only if student count is 3 or more than 3&lt;/P&gt;&lt;P&gt;STUD Dataset :&lt;/P&gt;&lt;P&gt;STUDID &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MARKS&lt;BR /&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 24&lt;BR /&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 24&lt;BR /&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 24&lt;BR /&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 24&lt;BR /&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 24&lt;BR /&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 24&lt;/P&gt;&lt;P&gt;O/P Requirement :&lt;/P&gt;&lt;P&gt;STUDID MARKS NEWVAR (U NEED TO CREATE)&lt;BR /&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 24 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 24 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;BR /&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 24 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;BR /&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 24 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 24 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;BR /&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 24 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can i get the output using proc freq procedure? (or) Which mehod is good to go?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2016 10:56:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count/m-p/315888#M68950</guid>
      <dc:creator>shahnaz</dc:creator>
      <dc:date>2016-12-01T10:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count/m-p/315890#M68951</link>
      <description>&lt;P&gt;Just use by processing and the correct syntax so newvar is automatically retained:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by studid;
if first.studid
then newvar = 1;
else newvar + 1; * this simple increment statement makes newvar a retained variable;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2016 11:22:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count/m-p/315890#M68951</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-12-01T11:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count/m-p/315891#M68952</link>
      <description>&lt;P&gt;Ohh Thank u soo much KurtBremser for the quick reply. And I have 1 more question for the same dataset:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Consider above student dataset and create a new dataset with only FIRST and LAST record of a student. If count =1 then no need to populate that record&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shahnaz&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2016 11:13:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count/m-p/315891#M68952</guid>
      <dc:creator>shahnaz</dc:creator>
      <dc:date>2016-12-01T11:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count/m-p/315892#M68953</link>
      <description>&lt;P&gt;Determine the number of obs per studid in an intermediate step and then merge with the original dataset.&lt;/P&gt;
&lt;P&gt;Note the use of the keep= option.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input studid marks;
cards;
1 24
1 24
1 24
2 24
2 24
3 24
;
run;

data int (keep=studid);
set have;
by studid;
if first.studid
then newvar = 1;
else newvar + 1;
if last.studid and newvar &amp;gt; 1;
run;

data want;
merge
  have
  int (in=a)
;
by studid;
if a and (first.studid or last.studid);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Dec 2016 11:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count/m-p/315892#M68953</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-12-01T11:21:31Z</dc:date>
    </item>
  </channel>
</rss>

