<?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: HELP NEEDED: Annual estimation using preceeding years only in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/HELP-NEEDED-Annual-estimation-using-preceeding-years-only/m-p/277023#M58705</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88921"&gt;@wriccar﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's assume, your WRDS_OUTPUT dataset contains data from 2001 through 2004. Now you could create three models per value of variable INDUSTRY:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;1. one for 2002 using the data with YEAR=2001 of the respective INDUSTRY&lt;BR /&gt;2. one for 2003 using the data with YEAR in (2001, 2002) of the respective INDUSTRY&lt;BR /&gt;3. one for 2004 using the data with YEAR in (2001, 2002, 2003) of the respective INDUSTRY&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this is what you want, I suggest:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=wrds_output;
by industry;
run;

data _null_;
do year=2002 to 2004;
  call execute(cats('proc reg data=wrds_output(where=(.z&amp;lt;year&amp;lt;',year,')) plots=none outest=param',year,';'));
  call execute('model dv = var1 var2;');
  call execute('by industry;');
  call execute('run;');
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The above code creates work datasets PARAM2002, PARAM2003 and PARAM2004 corresponding to items 1 - 3 above.&amp;nbsp;You can concatenate these datasets easily, if needed:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data param;
length year 8;
set param2002-param2004 indsname=dsn;
year=input(compress(dsn,,'kd'), 4.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 13 Jun 2016 18:43:24 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2016-06-13T18:43:24Z</dc:date>
    <item>
      <title>HELP NEEDED: Annual estimation using preceeding years only</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/HELP-NEEDED-Annual-estimation-using-preceeding-years-only/m-p/276998#M58701</link>
      <description>&lt;P&gt;Hello fellow SAS users!&lt;/P&gt;&lt;P&gt;I need some quick help writing a code that can produce estimated coefficients from an OLS Regression model each year using only the preceeding years' data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The model is:&lt;BR /&gt;DV&amp;nbsp;= var1 + var2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code is relatively straightforward:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC REG DATA=WRDS_OUTPUT PLOTS=NONE OUTEST=PARAM;
MODEL DV = VAR1 VAR2;
BY YEAR INDUSTRY; 
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;My dilemma is that I need to estimate the constant and coefficients on VAR1 and VAR2 using data through year&amp;nbsp;&lt;EM&gt;t-1&lt;/EM&gt;, which means the sample period will differ each year.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there an easy way to incorporate this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 17:10:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/HELP-NEEDED-Annual-estimation-using-preceeding-years-only/m-p/276998#M58701</guid>
      <dc:creator>wriccar</dc:creator>
      <dc:date>2016-06-13T17:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: HELP NEEDED: Annual estimation using preceeding years only</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/HELP-NEEDED-Annual-estimation-using-preceeding-years-only/m-p/277023#M58705</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88921"&gt;@wriccar﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's assume, your WRDS_OUTPUT dataset contains data from 2001 through 2004. Now you could create three models per value of variable INDUSTRY:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;1. one for 2002 using the data with YEAR=2001 of the respective INDUSTRY&lt;BR /&gt;2. one for 2003 using the data with YEAR in (2001, 2002) of the respective INDUSTRY&lt;BR /&gt;3. one for 2004 using the data with YEAR in (2001, 2002, 2003) of the respective INDUSTRY&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this is what you want, I suggest:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=wrds_output;
by industry;
run;

data _null_;
do year=2002 to 2004;
  call execute(cats('proc reg data=wrds_output(where=(.z&amp;lt;year&amp;lt;',year,')) plots=none outest=param',year,';'));
  call execute('model dv = var1 var2;');
  call execute('by industry;');
  call execute('run;');
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The above code creates work datasets PARAM2002, PARAM2003 and PARAM2004 corresponding to items 1 - 3 above.&amp;nbsp;You can concatenate these datasets easily, if needed:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data param;
length year 8;
set param2002-param2004 indsname=dsn;
year=input(compress(dsn,,'kd'), 4.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Jun 2016 18:43:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/HELP-NEEDED-Annual-estimation-using-preceeding-years-only/m-p/277023#M58705</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-06-13T18:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: HELP NEEDED: Annual estimation using preceeding years only</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/HELP-NEEDED-Annual-estimation-using-preceeding-years-only/m-p/279095#M58965</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh﻿&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the reply. This code worked perfectly and I thank you for it. I have one question, though you may not be able to answer without having access to the data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First, keep in mind I have already removed observations with missing values from the data set.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Second, my actual data set is from 1957 - 2016; I want to begin regressions as of 1972, so I adjusted the "do fyear=" statement of your code. It still worked.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem, though, is that until 1999 the regression doesn't run, saying there are no valid observations for each BY group. I thought this could be a problem of not having enough observations per industry classification, but it is giving the message for ALL industry groups. (Also, it gives the same message if I leave out the BY statement altogether.)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obviously this could be an issue for me to resolve looking through the data a bit more. But&amp;nbsp;I suppose my question is, does your code inherently require a number of prior years in order to run?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2016 16:59:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/HELP-NEEDED-Annual-estimation-using-preceeding-years-only/m-p/279095#M58965</guid>
      <dc:creator>wriccar</dc:creator>
      <dc:date>2016-06-21T16:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: HELP NEEDED: Annual estimation using preceeding years only</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/HELP-NEEDED-Annual-estimation-using-preceeding-years-only/m-p/279117#M58967</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88921"&gt;@wriccar﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This must be a data issue. Even a &lt;EM&gt;single&lt;/EM&gt; observation with non-missing values of DV, VAR1 and VAR2 (in the respective BY group) would prevent the message "ERROR: No valid observations are found." (The results based on a single observation would not be very useful, though.) So, in your case for many YEARs and apparently all values of INDUSTRY &lt;EM&gt;all&lt;/EM&gt; observations must have missing values of DV, VAR1 or VAR2. But if you "&lt;SPAN&gt;have already removed observations with missing values from the data set" (as you wrote), this situation should not occur.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;My test data had at least &lt;EM&gt;four&lt;/EM&gt; observations without missing values in each BY group (which is the minimum non-degenerate case).&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2016 19:12:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/HELP-NEEDED-Annual-estimation-using-preceeding-years-only/m-p/279117#M58967</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-06-21T19:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: HELP NEEDED: Annual estimation using preceeding years only</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/HELP-NEEDED-Annual-estimation-using-preceeding-years-only/m-p/279118#M58968</link>
      <description>&lt;P&gt;This was my thought, too. Just wanted to make sure.&lt;/P&gt;&lt;P&gt;I will give the data a thorough going-over.&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2016 19:13:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/HELP-NEEDED-Annual-estimation-using-preceeding-years-only/m-p/279118#M58968</guid>
      <dc:creator>wriccar</dc:creator>
      <dc:date>2016-06-21T19:13:50Z</dc:date>
    </item>
  </channel>
</rss>

