<?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: Counting the frequency of three consecutive yrs with first.obs taking the frequency as its count in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Counting-the-frequency-of-three-consecutive-yrs-with-first-obs/m-p/362803#M85749</link>
    <description>&lt;P&gt;That's technically Mrs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My question was does the answer above handle the situation above the way you expected.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't understand your response.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/143540"&gt;@nazmul&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Dear Mr. Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do not want to calculate the count in missing year. In my research, I am calculating the experience of bidders by counting the number of merger announcement they did in the last three years.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 May 2017 17:36:33 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-05-30T17:36:33Z</dc:date>
    <item>
      <title>Counting the frequency of three consecutive yrs with first.obs taking the frequency as its count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-the-frequency-of-three-consecutive-yrs-with-first-obs/m-p/362566#M85665</link>
      <description>&lt;P&gt;Hello Everone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to count the frequency of each observation for the three consequtive years.&amp;nbsp;The counting should consider the missing years also. &lt;STRONG&gt;I do not want to sum the frequency of three consecutive listed years instead I want the sum the frequency of three consecutive years.&amp;nbsp;&lt;/STRONG&gt;The count of the first observation of any id is equal to its own frequency and the count of the second consecutive observation of any id is equal to the sum of the frequency of the first and second consecutive years. Please help me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;input year id frequency;&lt;BR /&gt;1980 A 2&lt;BR /&gt;1982 A 1&lt;BR /&gt;1983 A 1&lt;BR /&gt;1986 A 2&lt;BR /&gt;1996 B 3&lt;BR /&gt;1997 B 2&lt;BR /&gt;1998 B 1&lt;BR /&gt;2001 B 5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The final output should look like the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/9124i68F67ECEA3F2CE3C/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Picture1.png" title="Picture1.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2017 22:49:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-the-frequency-of-three-consecutive-yrs-with-first-obs/m-p/362566#M85665</guid>
      <dc:creator>nazmul</dc:creator>
      <dc:date>2017-05-29T22:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the frequency of three consecutive yrs with first.obs taking the frequency as its count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-the-frequency-of-three-consecutive-yrs-with-first-obs/m-p/362577#M85669</link>
      <description>&lt;P&gt;What do you have so far?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;RETAIN &amp;amp; LAG/DIF will be the key components in this solution.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This doesn't make sense&amp;nbsp;by the way, you don't want to sum the three consecutive years, but you do? I'm assuming it's just bad phrasing but you should clarify.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;I do not want to sum the frequency of three consecutive listed years instead I want the sum the frequency of three consecutive years.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 00:25:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-the-frequency-of-three-consecutive-yrs-with-first-obs/m-p/362577#M85669</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-30T00:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the frequency of three consecutive yrs with first.obs taking the frequency as its count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-the-frequency-of-three-consecutive-yrs-with-first-obs/m-p/362581#M85670</link>
      <description>&lt;P&gt;You want to create a variable called COUNT - that much I can see.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The rules for creating COUNT are&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;For first.id,&amp;nbsp; COUNT=frequency&lt;/LI&gt;
&lt;LI&gt;Otherwise COUNT for a given year is the sum of frequency for Year, Year-1, and Year-2, correct?&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's say you know over all ID's, &amp;nbsp;your minyear=1980 and maxyear=2010.&amp;nbsp; If so, then make a array with bounds of 1978 (i.e. for 1980&amp;nbsp;minus 2 years)&amp;nbsp;and 2010, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input year id $ frequency;
datalines;
1980 A 2
1982 A 1
1983 A 1
1986 A 2
1996 B 3
1997 B 2
1998 B 1
2001 B 5
run;


data want;
  set have;
  by id;
  array frq {1978:2010} _temporary_;
  if first.id then call missing (of frq{*});
  frq{year}=frequency;
  count=sum(frq{year-2},frq{year-1},frq{year});
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 May 2017 00:42:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-the-frequency-of-three-consecutive-yrs-with-first-obs/m-p/362581#M85670</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-05-30T00:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the frequency of three consecutive yrs with first.obs taking the frequency as its count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-the-frequency-of-three-consecutive-yrs-with-first-obs/m-p/362582#M85671</link>
      <description>&lt;P&gt;Dear Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am sorry I could not explain the problem properly. Thank you so much for replying to my questI got my desired code from Mr.&amp;nbsp;&lt;SPAN&gt;mkeintz&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 01:26:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-the-frequency-of-three-consecutive-yrs-with-first-obs/m-p/362582#M85671</guid>
      <dc:creator>nazmul</dc:creator>
      <dc:date>2017-05-30T01:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the frequency of three consecutive yrs with first.obs taking the frequency as its count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-the-frequency-of-three-consecutive-yrs-with-first-obs/m-p/362583#M85672</link>
      <description>&lt;P&gt;Thank you Mr./Mrs.&amp;nbsp;&lt;SPAN&gt;mkeintz. Your code perfectly solved my problem&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 01:27:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-the-frequency-of-three-consecutive-yrs-with-first-obs/m-p/362583#M85672</guid>
      <dc:creator>nazmul</dc:creator>
      <dc:date>2017-05-30T01:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the frequency of three consecutive yrs with first.obs taking the frequency as its count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-the-frequency-of-three-consecutive-yrs-with-first-obs/m-p/362604#M85679</link>
      <description>&lt;P&gt;Does the case of data where you're missing the middle work as expected?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Year count&lt;/P&gt;
&lt;P&gt;1985 1 1&lt;/P&gt;
&lt;P&gt;1987 3 4&lt;/P&gt;
&lt;P&gt;1988 1 5?1???&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 04:28:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-the-frequency-of-three-consecutive-yrs-with-first-obs/m-p/362604#M85679</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-30T04:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the frequency of three consecutive yrs with first.obs taking the frequency as its count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-the-frequency-of-three-consecutive-yrs-with-first-obs/m-p/362773#M85734</link>
      <description>&lt;P&gt;Dear Mr. Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not want to calculate the count in missing year. In my research, I am calculating the experience of bidders by counting the number of merger announcement they did in the last three years.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 15:59:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-the-frequency-of-three-consecutive-yrs-with-first-obs/m-p/362773#M85734</guid>
      <dc:creator>nazmul</dc:creator>
      <dc:date>2017-05-30T15:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the frequency of three consecutive yrs with first.obs taking the frequency as its count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-the-frequency-of-three-consecutive-yrs-with-first-obs/m-p/362803#M85749</link>
      <description>&lt;P&gt;That's technically Mrs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My question was does the answer above handle the situation above the way you expected.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't understand your response.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/143540"&gt;@nazmul&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Dear Mr. Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do not want to calculate the count in missing year. In my research, I am calculating the experience of bidders by counting the number of merger announcement they did in the last three years.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 17:36:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-the-frequency-of-three-consecutive-yrs-with-first-obs/m-p/362803#M85749</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-30T17:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the frequency of three consecutive yrs with first.obs taking the frequency as its count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-the-frequency-of-three-consecutive-yrs-with-first-obs/m-p/362821#M85758</link>
      <description>I only checked code mkeintz posted in this conversation. That code&lt;BR /&gt;perfectly solved my problem. Thank you for asking. I am sorry for Mr. in&lt;BR /&gt;place of Ms. Have a good day!&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Tue, 30 May 2017 18:28:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-the-frequency-of-three-consecutive-yrs-with-first-obs/m-p/362821#M85758</guid>
      <dc:creator>nazmul</dc:creator>
      <dc:date>2017-05-30T18:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the frequency of three consecutive yrs with first.obs taking the frequency as its count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-the-frequency-of-three-consecutive-yrs-with-first-obs/m-p/364070#M86298</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying your code on my research. But the log file is showing the following errors. Could you please fix it? I will appreciate your help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;73 data want1;&lt;BR /&gt;74 set have1;&lt;BR /&gt;75 by ACUSIP;&lt;BR /&gt;76 array frq {1976:2017} _temporary_;&lt;BR /&gt;77 if first.ACUSIP then call missing (of frq{*});&lt;BR /&gt;78 frq{year}=frequency;&lt;BR /&gt;79 count=sum(frq{year-2},frq{year-1},frq{year});&lt;BR /&gt;80 run;&lt;/P&gt;&lt;P&gt;ERROR: Array subscript out of range at line 79 column 13.&lt;BR /&gt;year=1976 ACUSIP=46070010 frequency=1 FIRST.ACUSIP=1 LAST.ACUSIP=1 count=. _ERROR_=1 _N_=7175&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: There were 7176 observations read from the data set WORK.HAVE1.&lt;BR /&gt;WARNING: The data set WORK.WANT1 may be incomplete. When this step was stopped there were 7174&lt;BR /&gt;observations and 4 variables.&lt;BR /&gt;WARNING: Data set WORK.WANT1 was not replaced because this step was stopped.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.02 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Jun 2017 02:21:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-the-frequency-of-three-consecutive-yrs-with-first-obs/m-p/364070#M86298</guid>
      <dc:creator>nazmul</dc:creator>
      <dc:date>2017-06-04T02:21:51Z</dc:date>
    </item>
  </channel>
</rss>

