<?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: Calculation of consensus forecast in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Calculation-of-consensus-forecast/m-p/26369#M6022</link>
    <description>Hi.&lt;BR /&gt;
With my understand about your post.&lt;BR /&gt;
[pre]&lt;BR /&gt;
data temp;&lt;BR /&gt;
 infile datalines truncover;&lt;BR /&gt;
 input analyst $ company $ year quarter eps date $12.;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1a A 2000 1 4 2 jan 2000&lt;BR /&gt;
2a A 2000 1 4.5 9 jan 2000&lt;BR /&gt;
3a A 2000 1 4.9 14 febr 2000&lt;BR /&gt;
4a A 2000 1 4.1 19 febr 2000&lt;BR /&gt;
5a A 2000 1 4.3 27 febr 2000&lt;BR /&gt;
1a A 2000 2 4.7 15 mar 2000&lt;BR /&gt;
3a A 2000 2 4.7 19 mar 2000&lt;BR /&gt;
2a A 2000 2 5 29 apr 2000&lt;BR /&gt;
1b B 2000 1 10 etc&lt;BR /&gt;
2b B 2000 1 12&lt;BR /&gt;
3b B 2000 1 10.5&lt;BR /&gt;
4b B 2000 1 11&lt;BR /&gt;
2b B 2000 2 15&lt;BR /&gt;
1b B 2000 2 14&lt;BR /&gt;
3b B 2000 2 13&lt;BR /&gt;
5b B 2000 2 14 &lt;BR /&gt;
run;&lt;BR /&gt;
data result(drop=sum count);&lt;BR /&gt;
 set temp;&lt;BR /&gt;
 if quarter ne lag(quarter) then do;&lt;BR /&gt;
                                  Consensus=.;&lt;BR /&gt;
                                  sum=0;&lt;BR /&gt;
                                  count=0;&lt;BR /&gt;
                                 end;&lt;BR /&gt;
   else consensus=sum/count;&lt;BR /&gt;
 sum+eps;&lt;BR /&gt;
 count+1;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
    <pubDate>Fri, 11 Mar 2011 02:32:32 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2011-03-11T02:32:32Z</dc:date>
    <item>
      <title>Calculation of consensus forecast</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculation-of-consensus-forecast/m-p/26368#M6021</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I'm working on a study regarding forecast accuracy among financial analysts. At this moment I'm stuck calculating the analysts deviation from the consensus.&lt;BR /&gt;
&lt;BR /&gt;
Quote with definition of consensus: "The deviation from the consensus is determined as the difference between the analyst's forecast fikt and the consensus forecast ck&amp;#28; concerning the earnings per share. The consensus forecast proxies for&lt;BR /&gt;
available public information up to the point in time an analyst issues his forecast. This&lt;BR /&gt;
consensus forecast at time T&amp;#28; (within the quarter) is calculated as the mean of all the&lt;BR /&gt;
analysts estimates up to &amp;#28;T , excluding the estimate of the analyst i, who makes his&lt;BR /&gt;
estimate for quarter t (analogous to Chen and Jiang, 2006 and Zitzewitz, 2001)&lt;BR /&gt;
&lt;BR /&gt;
I'm having problems programming the calculation of this consensus. In the example below I will show you what the input data looks like and what the output data should be.&lt;BR /&gt;
&lt;BR /&gt;
I'm sorry that my table doesn't look good but it doesn't recognize the space i used&lt;BR /&gt;
If someone can tell me how to edit my table, I will edit it.&lt;BR /&gt;
&lt;BR /&gt;
&lt;U&gt;input data&lt;/U&gt;&lt;BR /&gt;
&lt;BR /&gt;
Analyst  Company    Year     Quarter  EPS-estimation  Forecast date&lt;BR /&gt;
1a            A             2000        1             4                      2 jan 2000&lt;BR /&gt;
2a            A             2000        1             4.5                   9 jan 2000&lt;BR /&gt;
3a            A             2000        1             4.9                   14 febr 2000&lt;BR /&gt;
4a            A             2000        1             4.1                   19 febr 2000&lt;BR /&gt;
5a            A             2000        1             4.3                   27 febr 2000&lt;BR /&gt;
1a            A             2000        2             4.7                   15 mar 2000&lt;BR /&gt;
3a            A             2000        2             4.7                   19 mar 2000&lt;BR /&gt;
2a            A             2000        2             5                       29 apr 2000&lt;BR /&gt;
1b            B             2000        1              10                      etc&lt;BR /&gt;
2b            B             2000        1              12&lt;BR /&gt;
3b            B             2000        1              10.5&lt;BR /&gt;
4b            B             2000        1               11&lt;BR /&gt;
2b            B             2000        2               15&lt;BR /&gt;
1b            B             2000        2               14&lt;BR /&gt;
3b            B             2000        2               13&lt;BR /&gt;
5b            B             2000        2               14 &lt;BR /&gt;
]&lt;BR /&gt;
&lt;U&gt;output data&lt;/U&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Analyst  Company    Year     Quarter  EPS-estimation  Forecast date    Consensus&lt;BR /&gt;
1a            A             2000        1             4                      2 jan 2000          &lt;BR /&gt;
2a            A             2000        1             4.5                   9 jan 2000            4&lt;BR /&gt;
3a            A             2000        1             4.9                   14 febr 2000         4.25&lt;BR /&gt;
4a            A             2000        1             4.1                   19 febr 2000         4.46&lt;BR /&gt;
5a            A             2000        1             4.3                   27 febr 2000         4.375&lt;BR /&gt;
1a            A             2000        2             4.7                   15 mar 2000         &lt;BR /&gt;
3a            A             2000        2             4.7                   19 mar 2000         4.7&lt;BR /&gt;
2a            A             2000        2             5                       29 apr 2000         4.7&lt;BR /&gt;
1b            B             2000        1              10                      etc                    &lt;BR /&gt;
2b            B             2000        1              12                                               10&lt;BR /&gt;
3b            B             2000        1              10.5                                            11&lt;BR /&gt;
4b            B             2000        1               11                                              10.833&lt;BR /&gt;
2b            B             2000        2               15                                               &lt;BR /&gt;
1b            B             2000        2               14                                             15 &lt;BR /&gt;
3b            B             2000        2               13                                             14.5&lt;BR /&gt;
5b            B             2000        2               14                                             14&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance!</description>
      <pubDate>Thu, 10 Mar 2011 11:58:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculation-of-consensus-forecast/m-p/26368#M6021</guid>
      <dc:creator>jebuske</dc:creator>
      <dc:date>2011-03-10T11:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation of consensus forecast</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculation-of-consensus-forecast/m-p/26369#M6022</link>
      <description>Hi.&lt;BR /&gt;
With my understand about your post.&lt;BR /&gt;
[pre]&lt;BR /&gt;
data temp;&lt;BR /&gt;
 infile datalines truncover;&lt;BR /&gt;
 input analyst $ company $ year quarter eps date $12.;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1a A 2000 1 4 2 jan 2000&lt;BR /&gt;
2a A 2000 1 4.5 9 jan 2000&lt;BR /&gt;
3a A 2000 1 4.9 14 febr 2000&lt;BR /&gt;
4a A 2000 1 4.1 19 febr 2000&lt;BR /&gt;
5a A 2000 1 4.3 27 febr 2000&lt;BR /&gt;
1a A 2000 2 4.7 15 mar 2000&lt;BR /&gt;
3a A 2000 2 4.7 19 mar 2000&lt;BR /&gt;
2a A 2000 2 5 29 apr 2000&lt;BR /&gt;
1b B 2000 1 10 etc&lt;BR /&gt;
2b B 2000 1 12&lt;BR /&gt;
3b B 2000 1 10.5&lt;BR /&gt;
4b B 2000 1 11&lt;BR /&gt;
2b B 2000 2 15&lt;BR /&gt;
1b B 2000 2 14&lt;BR /&gt;
3b B 2000 2 13&lt;BR /&gt;
5b B 2000 2 14 &lt;BR /&gt;
run;&lt;BR /&gt;
data result(drop=sum count);&lt;BR /&gt;
 set temp;&lt;BR /&gt;
 if quarter ne lag(quarter) then do;&lt;BR /&gt;
                                  Consensus=.;&lt;BR /&gt;
                                  sum=0;&lt;BR /&gt;
                                  count=0;&lt;BR /&gt;
                                 end;&lt;BR /&gt;
   else consensus=sum/count;&lt;BR /&gt;
 sum+eps;&lt;BR /&gt;
 count+1;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Fri, 11 Mar 2011 02:32:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculation-of-consensus-forecast/m-p/26369#M6022</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-03-11T02:32:32Z</dc:date>
    </item>
  </channel>
</rss>

