<?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 how to get pre-ranking beta in FAMA-FRENCH 92 paper in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-get-pre-ranking-beta-in-FAMA-FRENCH-92-paper/m-p/335734#M272363</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on the fama french paper and want to estimate the pre ranking betas. These betas are based on returns that each securities had 5 years ago. I used the following code in an attempt to achieve this;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; first;&lt;/P&gt;&lt;P&gt;set size1(keep=permno date);&lt;/P&gt;&lt;P&gt;by permno;&lt;/P&gt;&lt;P&gt;retain firstdate;&lt;/P&gt;&lt;P&gt;date=intnx('month', date, &lt;STRONG&gt;1&lt;/STRONG&gt;)-&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;if first.permno then firstdate=date;&lt;/P&gt;&lt;P&gt;if last.permno then do;&lt;/P&gt;&lt;P&gt;lastdate=date;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; firstandlastdates;&lt;/P&gt;&lt;P&gt;set first;&lt;/P&gt;&lt;P&gt;format firstdate yymmdd10.;&lt;/P&gt;&lt;P&gt;format lastdate yymmdd10.;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; permnosrankdates(rename=(date=rankdate));&lt;/P&gt;&lt;P&gt;set firstandlastdates;&lt;/P&gt;&lt;P&gt;date=firstdate;&lt;/P&gt;&lt;P&gt;do while(date&amp;lt;=lastdate);&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;date=intnx('month', date+&lt;STRONG&gt;1&lt;/STRONG&gt;, &lt;STRONG&gt;1&lt;/STRONG&gt;)-&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; permnosrankdates;&lt;/P&gt;&lt;P&gt;set permnosrankdates;&lt;/P&gt;&lt;P&gt;date=rankdate;&lt;/P&gt;&lt;P&gt;i=&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;do while(i&amp;lt;=&lt;STRONG&gt;60&lt;/STRONG&gt;);&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;date=intnx ('month', date, &lt;STRONG&gt;0&lt;/STRONG&gt;)-&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;i=i+&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; permnosrankdates;&lt;/P&gt;&lt;P&gt;set permnosrankdates;&lt;/P&gt;&lt;P&gt;format date yymmdd10.;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; ff;&lt;/P&gt;&lt;P&gt;set size1 (keep=date ret vwretd exchcd);&lt;/P&gt;&lt;P&gt;date=intnx('month', date, &lt;STRONG&gt;1&lt;/STRONG&gt;)-&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sort&lt;/STRONG&gt; data=permnosrankdates;&lt;/P&gt;&lt;P&gt;by date permno;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sort&lt;/STRONG&gt; data=ff;&lt;/P&gt;&lt;P&gt;by date;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; permnosrankdates;&lt;/P&gt;&lt;P&gt;merge permnosrankdates(in=a) ff(in=b);&lt;/P&gt;&lt;P&gt;by date;&lt;/P&gt;&lt;P&gt;if a and b;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; msf;&lt;/P&gt;&lt;P&gt;set size1(keep=permno date&amp;nbsp; ret vwretd&amp;nbsp; exchcd);&lt;/P&gt;&lt;P&gt;where ret is not missing;&lt;/P&gt;&lt;P&gt;date=intnx('month', date, &lt;STRONG&gt;1&lt;/STRONG&gt;)-&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sort&lt;/STRONG&gt; data=msf;&lt;/P&gt;&lt;P&gt;by date permno;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; permnosrankdates;&lt;/P&gt;&lt;P&gt;merge permnosrankdates(in=a) msf(in=b);&lt;/P&gt;&lt;P&gt;by date permno;&lt;/P&gt;&lt;P&gt;if a and b;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;Some output was obtained, however i got some very high beta values (for example -1500) when i ran the regressions later which suggests that something went wrong. Could anyone please help me to identify mistake in this code? Did this code lag the values correctly?&lt;BR /&gt;In addition, I also tried to lag the data by 60 months by using the regular lag function. This also doesn't work as the data I have is a cross section (panel data) of returns and stocks for the time period (1980-2015). Converting the date to yyyymm format and then lagging by 60 months doesn't help either.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So my question is: How can I obtain the 60 months lagged returns of securites for a cross section of stock returns that is identified by and id variable=permno and a time varieable date? Could anyone please write the correct sas code for this problem? The data I am using is the cross section of stock returns for given dates.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would be greatful for any reply and help. I look forward for a reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Akarsh&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS: i am using sas version 9.4&lt;/P&gt;</description>
    <pubDate>Fri, 24 Feb 2017 20:44:37 GMT</pubDate>
    <dc:creator>Akarsh91</dc:creator>
    <dc:date>2017-02-24T20:44:37Z</dc:date>
    <item>
      <title>how to get pre-ranking beta in FAMA-FRENCH 92 paper</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-get-pre-ranking-beta-in-FAMA-FRENCH-92-paper/m-p/335734#M272363</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on the fama french paper and want to estimate the pre ranking betas. These betas are based on returns that each securities had 5 years ago. I used the following code in an attempt to achieve this;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; first;&lt;/P&gt;&lt;P&gt;set size1(keep=permno date);&lt;/P&gt;&lt;P&gt;by permno;&lt;/P&gt;&lt;P&gt;retain firstdate;&lt;/P&gt;&lt;P&gt;date=intnx('month', date, &lt;STRONG&gt;1&lt;/STRONG&gt;)-&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;if first.permno then firstdate=date;&lt;/P&gt;&lt;P&gt;if last.permno then do;&lt;/P&gt;&lt;P&gt;lastdate=date;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; firstandlastdates;&lt;/P&gt;&lt;P&gt;set first;&lt;/P&gt;&lt;P&gt;format firstdate yymmdd10.;&lt;/P&gt;&lt;P&gt;format lastdate yymmdd10.;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; permnosrankdates(rename=(date=rankdate));&lt;/P&gt;&lt;P&gt;set firstandlastdates;&lt;/P&gt;&lt;P&gt;date=firstdate;&lt;/P&gt;&lt;P&gt;do while(date&amp;lt;=lastdate);&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;date=intnx('month', date+&lt;STRONG&gt;1&lt;/STRONG&gt;, &lt;STRONG&gt;1&lt;/STRONG&gt;)-&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; permnosrankdates;&lt;/P&gt;&lt;P&gt;set permnosrankdates;&lt;/P&gt;&lt;P&gt;date=rankdate;&lt;/P&gt;&lt;P&gt;i=&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;do while(i&amp;lt;=&lt;STRONG&gt;60&lt;/STRONG&gt;);&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;date=intnx ('month', date, &lt;STRONG&gt;0&lt;/STRONG&gt;)-&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;i=i+&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; permnosrankdates;&lt;/P&gt;&lt;P&gt;set permnosrankdates;&lt;/P&gt;&lt;P&gt;format date yymmdd10.;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; ff;&lt;/P&gt;&lt;P&gt;set size1 (keep=date ret vwretd exchcd);&lt;/P&gt;&lt;P&gt;date=intnx('month', date, &lt;STRONG&gt;1&lt;/STRONG&gt;)-&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sort&lt;/STRONG&gt; data=permnosrankdates;&lt;/P&gt;&lt;P&gt;by date permno;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sort&lt;/STRONG&gt; data=ff;&lt;/P&gt;&lt;P&gt;by date;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; permnosrankdates;&lt;/P&gt;&lt;P&gt;merge permnosrankdates(in=a) ff(in=b);&lt;/P&gt;&lt;P&gt;by date;&lt;/P&gt;&lt;P&gt;if a and b;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; msf;&lt;/P&gt;&lt;P&gt;set size1(keep=permno date&amp;nbsp; ret vwretd&amp;nbsp; exchcd);&lt;/P&gt;&lt;P&gt;where ret is not missing;&lt;/P&gt;&lt;P&gt;date=intnx('month', date, &lt;STRONG&gt;1&lt;/STRONG&gt;)-&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sort&lt;/STRONG&gt; data=msf;&lt;/P&gt;&lt;P&gt;by date permno;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; permnosrankdates;&lt;/P&gt;&lt;P&gt;merge permnosrankdates(in=a) msf(in=b);&lt;/P&gt;&lt;P&gt;by date permno;&lt;/P&gt;&lt;P&gt;if a and b;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;Some output was obtained, however i got some very high beta values (for example -1500) when i ran the regressions later which suggests that something went wrong. Could anyone please help me to identify mistake in this code? Did this code lag the values correctly?&lt;BR /&gt;In addition, I also tried to lag the data by 60 months by using the regular lag function. This also doesn't work as the data I have is a cross section (panel data) of returns and stocks for the time period (1980-2015). Converting the date to yyyymm format and then lagging by 60 months doesn't help either.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So my question is: How can I obtain the 60 months lagged returns of securites for a cross section of stock returns that is identified by and id variable=permno and a time varieable date? Could anyone please write the correct sas code for this problem? The data I am using is the cross section of stock returns for given dates.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would be greatful for any reply and help. I look forward for a reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Akarsh&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS: i am using sas version 9.4&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2017 20:44:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-get-pre-ranking-beta-in-FAMA-FRENCH-92-paper/m-p/335734#M272363</guid>
      <dc:creator>Akarsh91</dc:creator>
      <dc:date>2017-02-24T20:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to get pre-ranking beta in FAMA-FRENCH 92 paper</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-get-pre-ranking-beta-in-FAMA-FRENCH-92-paper/m-p/335782#M272364</link>
      <description>&lt;P&gt;Ordinarily you would get no answers to this question becuase you did not provide sample data for SIZE1, for FF, and for your desired outcome.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I believe I am familiar with the particular data sources you are using.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have data in SIZE1 sorted by permno/date in dataset size1, right?&amp;nbsp; I guess it's CRSP monthly data, where the date is the last trading day of the month.&amp;nbsp;&amp;nbsp; You want to merge it with FF data, which I believe is also monthly, but is only a single series (i.e. no permno) and apparently uses last calendar date of the month.&amp;nbsp; If that's the case, then it's best to load the FF into a lookup table (called a hash object below) and just retrieve the needed values by means of hash lookup.&amp;nbsp; No need for all your sorting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data need;
  set size1;
  if _n_=1 then do;
    if 0 then set FF;
    declare hash ffdata(dataset:'ff');
        ff.definekey('date');
        ff.definedata(all:'Y');
        ff.definedone();
  end;
  date=intnx('month',date,0,'end');
  rc=ffdata.find();
  date60=intnx('month',date,-60,'end');
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notes:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The hash object
&lt;OL&gt;
&lt;LI&gt;Is automatically "retained". That's why it is generated and populated only under the "IF _N_=1" do group.&amp;nbsp; You only need to create the hash object once.&amp;nbsp; "IF _N_=1" means to do this only during the first iteration of the data step (which usually means when processing the first observation).&lt;/LI&gt;
&lt;LI&gt;The "if 0 then set ff" statement tells sas to make entries in the program data vector for all the FF vars, but don't bother actually reading in the FF data.&lt;/LI&gt;
&lt;LI&gt;The hash object FFDATA, in this case, just takes in all the FF data:&amp;nbsp; &lt;STRONG&gt;declare hash ffdata(dataset:'FF')&lt;/STRONG&gt; .&amp;nbsp; The are many attributes of the hash object that I won't go into, but are particulary useful for your task.&lt;/LI&gt;
&lt;LI&gt;It is "keyed" (indexed) on the date var:&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;ffdata.definekey('date')&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;The data to be retrieved via that key is all the vars in FF:&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;ffdata.definedata(all:'Y')&lt;/STRONG&gt;.&amp;nbsp; If you only want some of the vars (say vars a b and c), you could just change the declare statement to&amp;nbsp;&amp;nbsp; &lt;EM&gt;&lt;STRONG&gt;declare hash ffdata(dataset:'FF (keep=date a b c)');&lt;/STRONG&gt;&lt;/EM&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI&gt;Getting end-of-month dates.&amp;nbsp; You don't need date=intnx('month',date,1)-1&amp;nbsp; You can use the alignment parameter 'end", as in &lt;STRONG&gt;date=intnx('month',date,0,'end')&lt;/STRONG&gt;.&lt;/LI&gt;
&lt;LI&gt;rc=ffdata.find() says to get the FF data for the date of the incoming SIZE1 observation.&amp;nbsp; RC=0 upon a successful lookup.&lt;/LI&gt;
&lt;LI&gt;Data set need now has ...&lt;/LI&gt;
&lt;OL&gt;
&lt;LI&gt;Monthly data sorted by permno/date&lt;/LI&gt;
&lt;LI&gt;date=last calendar date of the month&lt;/LI&gt;
&lt;LI&gt;all the vars in SIZE1&lt;/LI&gt;
&lt;LI&gt;all the vars in FF for the same month&lt;/LI&gt;
&lt;LI&gt;A 2nd date variable DATE60, which has the date for 60 months prior.&lt;/LI&gt;
&lt;/OL&gt;
&lt;/OL&gt;
&lt;P&gt;This assumes, of course, that the FF has all the date values found in SIZE1 (after end-of-month adjustment).&amp;nbsp; Otherwise some FF values will be erroneous in the progarm above.&amp;nbsp; You would need to explicitly set them to missing&amp;nbsp;whenever RC^=0.&amp;nbsp;&amp;nbsp;So take a look at NEED before you run the program below to generate WANT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now you want 60 month lagged returns. For record J of a given permno you can just find record K of the same permno where DATE60 for J = DATE for K.&amp;nbsp; That's straightforward:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge need (in=incurrent
        need (in=in60months keep=date ret vwretd rename=(date=date60 ret=ret60 vwretd=vwretd60));
  by permno date60;
  if incurrent and in60months;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Now data WANT is still sorted by permno/date&amp;nbsp; (and also by permno/date60).&lt;/LI&gt;
&lt;LI&gt;It only has complete records, i.e.for which there are both current and 60-month prior data&amp;nbsp; (that's the "if incurrent and in60months").&lt;/LI&gt;
&lt;LI&gt;it has 2 new vars:&amp;nbsp;&amp;nbsp; ret60 an vwretd60 represented the 60 month lagged data.&amp;nbsp;&amp;nbsp; You can obviously get some lagged FF vars too by adding them to the "keep="&amp;nbsp; and "rename=" parameters&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Fri, 24 Feb 2017 22:22:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-get-pre-ranking-beta-in-FAMA-FRENCH-92-paper/m-p/335782#M272364</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-02-24T22:22:54Z</dc:date>
    </item>
  </channel>
</rss>

