<?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: Event study and Date problem... in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Event-study-and-Date-problem/m-p/48307#M9984</link>
    <description>Thanks Cynthia;&lt;BR /&gt;
&lt;BR /&gt;
Universe dataset -- how is the quarter information represented&lt;BR /&gt;
--with a single date variable. However the table shows two equivelant date representations:&lt;BR /&gt;
1) "&lt;I&gt;datadate&lt;/I&gt;"  Character form like &lt;B&gt;31-Mar-99&lt;/B&gt;, and&lt;BR /&gt;
2)"&lt;I&gt;datacqtr&lt;/I&gt;" Numeric form like &lt;B&gt;1999.1&lt;/B&gt; (means quarter 1 year 1999) &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Sample dataset -- how is the DEAL Date represented&lt;BR /&gt;
--with a single date variable. "&lt;I&gt;dealdate&lt;/I&gt;" and it's Numeric like &lt;B&gt;12DEC2008&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
Coming to the common variable, both datasets have &lt;I&gt;gvkey&lt;/I&gt; to represent the acquirers (I mean firms). &lt;BR /&gt;
&lt;BR /&gt;
Yes this is true. Each observation is a firm-quarter.&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;UNIVERSE:&lt;/B&gt;&lt;BR /&gt;
  [pre]          &lt;BR /&gt;
              	Obs           gvkey    datadate         datacqtr    sic2    lag4_roa&lt;BR /&gt;
&lt;BR /&gt;
                1            1235    30-Jun-99          1999.2     22      0.01534&lt;BR /&gt;
                2            1235    30-Sep-99          1999.3     22      0.02700&lt;BR /&gt;
                3            1235    31-Mar-99          1999.1     22      0.01663&lt;BR /&gt;
                4            1278    30-Jun-00          2000.2     23     -0.01379&lt;BR /&gt;
                5            1278    30-Jun-99          1999.2     23     -0.09581&lt;BR /&gt;
                6            1278    30-Sep-00          2000.3     23     -0.01427&lt;BR /&gt;
                7            1278    30-Sep-99          1999.3     23     -0.05392&lt;BR /&gt;
                8            1278    31-Dec-99          1999.4     23     -0.09128&lt;BR /&gt;
                9            1278    31-Mar-00          2000.1     23     -0.01787&lt;BR /&gt;
               10            1278    31-Mar-99          1999.1     23     -0.01613&lt;BR /&gt;
               11            1496    30-Jun-00          2000.2     25      0.06021&lt;BR /&gt;
               12            1496    30-Jun-01          2001.2     25      0.05269&lt;BR /&gt;
               13            1496    30-Jun-02          2002.2     25      0.05435&lt;BR /&gt;
               14            1496    30-Jun-03          2003.2     25      0.02923&lt;BR /&gt;
               15            1496    30-Jun-04          2004.2     25      0.02190&lt;BR /&gt;
               16            1496    30-Jun-05          2005.2     25      0.01718&lt;BR /&gt;
               17            1496    30-Jun-06          2006.2     25     -0.01955&lt;BR /&gt;
               18            1496    30-Jun-07          2007.2     25      0.00963&lt;BR /&gt;
               19            1496    30-Jun-08          2008.2     25     -0.00479&lt;BR /&gt;
               20            1496    30-Jun-99          1999.2     25      0.08410&lt;BR /&gt;
               21            1496    30-Sep-00          2000.3     25      0.03563&lt;BR /&gt;
               22            1496    30-Sep-01          2001.3     25      0.03606&lt;BR /&gt;
               23            1496    30-Sep-02          2002.3     25      0.02185&lt;BR /&gt;
               24            1496    30-Sep-03          2003.3     25      0.02684&lt;BR /&gt;
               25            1496    30-Sep-04          2004.3     25      0.01826&lt;BR /&gt;
               26            1496    30-Sep-05          2005.3     25      0.06419&lt;BR /&gt;
               27            1496    30-Sep-06          2006.3     25     -0.03246&lt;BR /&gt;
               28            1496    30-Sep-07          2007.3     25      0.00816&lt;BR /&gt;
               29            1496    30-Sep-08          2008.3     25     -0.03550&lt;BR /&gt;
               30            1496    30-Sep-99          1999.3     25      0.08177&lt;BR /&gt;
               31            1496    31-Dec-00          2000.4     25      0.04078&lt;BR /&gt;
               32            1496    31-Dec-01          2001.4     25      0.06475&lt;BR /&gt;
               33            1496    31-Dec-02          2002.4     25      0.02916&lt;BR /&gt;
               34            1496    31-Dec-03          2003.4     25      0.02524&lt;BR /&gt;
               35            1496    31-Dec-04          2004.4     25      0.02744&lt;BR /&gt;
               36            1496    31-Dec-05          2005.4     25     -0.00787&lt;BR /&gt;
               37            1496    31-Dec-06          2006.4     25     -0.09617&lt;BR /&gt;
               38            1496    31-Dec-07          2007.4     25     -0.00332&lt;BR /&gt;
               39            1496    31-Dec-99          1999.4     25      0.06719&lt;BR /&gt;
               40            1496    31-Mar-00          2000.1     25      0.04244&lt;BR /&gt;
               41            1496    31-Mar-01          2001.1     25      0.03444&lt;BR /&gt;
               42            1496    31-Mar-02          2002.1     25      0.04240&lt;BR /&gt;
               43            1496    31-Mar-03          2003.1     25      0.02642&lt;BR /&gt;
               44            1496    31-Mar-04          2004.1     25      0.01729&lt;BR /&gt;
               45            1496    31-Mar-05          2005.1     25      0.02409&lt;BR /&gt;
               46            1496    31-Mar-06          2006.1     25     -0.26155&lt;BR /&gt;
               47            1496    31-Mar-07          2007.1     25      0.02740&lt;BR /&gt;
               48            1496    31-Mar-08          2008.1     25     -0.00994&lt;BR /&gt;
               49            1496    31-Mar-99          1999.1     25      0.07676&lt;BR /&gt;
               50            1992    30-Jun-00          2000.2     24      0.01341&lt;BR /&gt;
               &lt;BR /&gt;
 [/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;SAMPLE:&lt;/B&gt;&lt;BR /&gt;
 [pre]		Obs     dealdate    Acq                                gvkey    id&lt;BR /&gt;
&lt;BR /&gt;
                 1    12DEC2008    International Tech Sys Inc             .     1&lt;BR /&gt;
                 2    09DEC2008    AO Smith Corp                       9771     2&lt;BR /&gt;
                 3    01DEC2008    Johnson &amp;amp; Johnson                   6266     3&lt;BR /&gt;
                 4    24NOV2008    Kratos Defense &amp;amp; Security         126056     4&lt;BR /&gt;
                 5    24NOV2008    Johnson &amp;amp; Johnson                   6266     5&lt;BR /&gt;
                 6    28OCT2008    Clinical Data Inc                   3116     6&lt;BR /&gt;
                 7    27OCT2008    CenturyTel Inc                      2884     7&lt;BR /&gt;
                 8    06OCT2008    Eli Lilly &amp;amp; Co                     65152     8&lt;BR /&gt;
                 9    24SEP2008    Ligand Pharmaceuticals Inc         12495     9&lt;BR /&gt;
                10    22SEP2008    McAfee Inc                         14401    10&lt;BR /&gt;
                11    15SEP2008    Best Buy Co Inc                     2184    11&lt;BR /&gt;
                12    03SEP2008    Park City Group Inc               116166    13&lt;BR /&gt;
                13    02SEP2008    Teradyne Inc                       10453    14&lt;BR /&gt;
                14    22AUG2008    King Pharmaceuticals Inc          112033    16&lt;BR /&gt;
                15    12AUG2008    The Middleby Corp                  13570    17&lt;BR /&gt;
                16    12AUG2008    CVS Caremark Corp                  28654    18&lt;BR /&gt;
                17    07AUG2008    Stream Global Services Inc        178633    19&lt;BR /&gt;
                18    05AUG2008    Planet Hollywood International     62676    20&lt;BR /&gt;
                19    28JUL2008    Sempra Energy Inc                   8272    21&lt;BR /&gt;
                20    21JUL2008    Brocade Commun Sys Inc            120774    22&lt;BR /&gt;
                21    17JUL2008    ON Semiconductor Corp              18914    23&lt;BR /&gt;
                22    16JUL2008    Convergys Corp                    149697    24&lt;BR /&gt;
                23    11JUL2008    Ashland Inc                         1794    26&lt;BR /&gt;
                24    10JUL2008    Access Pharmaceuticals Inc         12713    27&lt;BR /&gt;
                25    10JUL2008    GSI Group Inc                      61356    28&lt;BR /&gt;
                26    09JUL2008    TranSwitch Corp                    60846    29&lt;BR /&gt;
                27    08JUL2008    Eli Lilly &amp;amp; Co                    122895    30&lt;BR /&gt;
                28    26JUN2008    Liberty Media Corp                174168    31&lt;BR /&gt;
                29    23JUN2008    Republic Services Inc             112168    32&lt;BR /&gt;
                30    19JUN2008    TIBCO Software Inc                122061    34&lt;BR /&gt;
                31    09JUN2008    CytRx Corp                         13184    36&lt;BR /&gt;
                32    09JUN2008    Hologic Inc                        65908    37&lt;BR /&gt;
                33    03JUN2008    Smith International Inc             9772    38&lt;BR /&gt;
                34    29MAY2008    Blackbaud Inc                     260893    39&lt;BR /&gt;
                35    28MAY2008    Bristol-Myers Squibb Co           162502    40&lt;BR /&gt;
                36    27MAY2008    Provide Commerce Inc              156415    41&lt;BR /&gt;
                37    16MAY2008    Finisar Corp                      126417    43&lt;BR /&gt;
                38    15MAY2008    CBS Corp                           13714    44&lt;BR /&gt;
                39    13MAY2008    Hewlett-Packard Co                  4537    45&lt;BR /&gt;
                40    12MAY2008    Comtech Telecommun Corp             3358    46&lt;BR /&gt;
                41    08MAY2008    DG FastChannel Inc                 62016    47&lt;BR /&gt;
                42    01MAY2008    Autodesk Inc                        1878    48&lt;BR /&gt;
                43    30APR2008    Stone Energy Corp                  64835    49&lt;BR /&gt;
                44    30APR2008    United Online Inc                 124198    50&lt;BR /&gt;
                45    22APR2008    Medtronic Inc                     178526    51&lt;BR /&gt;
                46    21APR2008    Blue Coat Systems Inc             126615    52&lt;BR /&gt;
                47    15APR2008    Boston Scientific Corp            119214    54&lt;BR /&gt;
                48    14APR2008    Delta Air Lines Inc                 2605    55&lt;BR /&gt;
                49    11APR2008    Cypress Semiconductor Corp         12215    57&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Malek</description>
    <pubDate>Thu, 28 Jan 2010 18:09:12 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-01-28T18:09:12Z</dc:date>
    <item>
      <title>Event study and Date problem...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Event-study-and-Date-problem/m-p/48304#M9981</link>
      <description>Hi,&lt;BR /&gt;
 &lt;BR /&gt;
I am having a problem with getting a code for my event study.&lt;BR /&gt;
 &lt;BR /&gt;
1) I have two datasets, Universe and Sample.&lt;BR /&gt;
-Universe dataset contains ALL companies quarters.&lt;BR /&gt;
-Sample dataset contains merger &amp;amp; acquisition acquirers and their DEAL DATES.&lt;BR /&gt;
2) I want to combine the two datasets as: for each acquirer, I want the data of 4 quarters BEFORE the DEAL DATE. (i.e. the last 4 observations before the M&amp;amp;A date).&lt;BR /&gt;
&lt;BR /&gt;
Malek</description>
      <pubDate>Thu, 28 Jan 2010 14:33:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Event-study-and-Date-problem/m-p/48304#M9981</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-01-28T14:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: Event study and Date problem...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Event-study-and-Date-problem/m-p/48305#M9982</link>
      <description>Hi:&lt;BR /&gt;
  A bit more information is needed. For example...&lt;BR /&gt;
&lt;BR /&gt;
With the Universe dataset -- how is the quarter information represented&lt;BR /&gt;
--with a separate year variable and a separate quarter variable&lt;BR /&gt;
--with a single date variable&lt;BR /&gt;
--is the date information in numeric or character form&lt;BR /&gt;
&lt;BR /&gt;
With the Sample dataset -- how is the DEAL Date represented&lt;BR /&gt;
--with a separate year variable, month variable and day variable&lt;BR /&gt;
--with a single date variable&lt;BR /&gt;
--is the date information in numeric or character form&lt;BR /&gt;
&lt;BR /&gt;
What is the common variable or variables for joining, combining or merging the 2 datasets together??? &lt;BR /&gt;
&lt;BR /&gt;
When you say you are looking for the last 4 observations before the M&amp;amp;A date, it sounds like every quarter is a separate observation in the Universe file. Is this true?&lt;BR /&gt;
 &lt;BR /&gt;
Can you show the program or SQL query that you have tried? &lt;BR /&gt;
&lt;BR /&gt;
Can you show a sample of the data from the two datasets or make up some dummy data that shows the structure of the 2 files?&lt;BR /&gt;
&lt;BR /&gt;
For posting data or maintaining the indention of code, this previous forum posting is very helpful:&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=27609毙" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=27609毙&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Thu, 28 Jan 2010 16:33:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Event-study-and-Date-problem/m-p/48305#M9982</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-01-28T16:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: Event study and Date problem...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Event-study-and-Date-problem/m-p/48306#M9983</link>
      <description>Additional question back to the OP (unless Cynthia already asked it):&lt;BR /&gt;
&lt;BR /&gt;
-- how do you correlate/identify acquired companies and who acquired them?  Is there some variable/column containing "Acquired_By"?&lt;BR /&gt;
&lt;BR /&gt;
Definitely need to see more input data descriptive information, as in file/column layout and a sample subset of data values from the OP, submitted as a post/reply using PASTE (preferred over hand-keyed for accuracy).  Of course, any SAS code already written by the OP would be helpful.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 28 Jan 2010 17:11:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Event-study-and-Date-problem/m-p/48306#M9983</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-01-28T17:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: Event study and Date problem...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Event-study-and-Date-problem/m-p/48307#M9984</link>
      <description>Thanks Cynthia;&lt;BR /&gt;
&lt;BR /&gt;
Universe dataset -- how is the quarter information represented&lt;BR /&gt;
--with a single date variable. However the table shows two equivelant date representations:&lt;BR /&gt;
1) "&lt;I&gt;datadate&lt;/I&gt;"  Character form like &lt;B&gt;31-Mar-99&lt;/B&gt;, and&lt;BR /&gt;
2)"&lt;I&gt;datacqtr&lt;/I&gt;" Numeric form like &lt;B&gt;1999.1&lt;/B&gt; (means quarter 1 year 1999) &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Sample dataset -- how is the DEAL Date represented&lt;BR /&gt;
--with a single date variable. "&lt;I&gt;dealdate&lt;/I&gt;" and it's Numeric like &lt;B&gt;12DEC2008&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
Coming to the common variable, both datasets have &lt;I&gt;gvkey&lt;/I&gt; to represent the acquirers (I mean firms). &lt;BR /&gt;
&lt;BR /&gt;
Yes this is true. Each observation is a firm-quarter.&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;UNIVERSE:&lt;/B&gt;&lt;BR /&gt;
  [pre]          &lt;BR /&gt;
              	Obs           gvkey    datadate         datacqtr    sic2    lag4_roa&lt;BR /&gt;
&lt;BR /&gt;
                1            1235    30-Jun-99          1999.2     22      0.01534&lt;BR /&gt;
                2            1235    30-Sep-99          1999.3     22      0.02700&lt;BR /&gt;
                3            1235    31-Mar-99          1999.1     22      0.01663&lt;BR /&gt;
                4            1278    30-Jun-00          2000.2     23     -0.01379&lt;BR /&gt;
                5            1278    30-Jun-99          1999.2     23     -0.09581&lt;BR /&gt;
                6            1278    30-Sep-00          2000.3     23     -0.01427&lt;BR /&gt;
                7            1278    30-Sep-99          1999.3     23     -0.05392&lt;BR /&gt;
                8            1278    31-Dec-99          1999.4     23     -0.09128&lt;BR /&gt;
                9            1278    31-Mar-00          2000.1     23     -0.01787&lt;BR /&gt;
               10            1278    31-Mar-99          1999.1     23     -0.01613&lt;BR /&gt;
               11            1496    30-Jun-00          2000.2     25      0.06021&lt;BR /&gt;
               12            1496    30-Jun-01          2001.2     25      0.05269&lt;BR /&gt;
               13            1496    30-Jun-02          2002.2     25      0.05435&lt;BR /&gt;
               14            1496    30-Jun-03          2003.2     25      0.02923&lt;BR /&gt;
               15            1496    30-Jun-04          2004.2     25      0.02190&lt;BR /&gt;
               16            1496    30-Jun-05          2005.2     25      0.01718&lt;BR /&gt;
               17            1496    30-Jun-06          2006.2     25     -0.01955&lt;BR /&gt;
               18            1496    30-Jun-07          2007.2     25      0.00963&lt;BR /&gt;
               19            1496    30-Jun-08          2008.2     25     -0.00479&lt;BR /&gt;
               20            1496    30-Jun-99          1999.2     25      0.08410&lt;BR /&gt;
               21            1496    30-Sep-00          2000.3     25      0.03563&lt;BR /&gt;
               22            1496    30-Sep-01          2001.3     25      0.03606&lt;BR /&gt;
               23            1496    30-Sep-02          2002.3     25      0.02185&lt;BR /&gt;
               24            1496    30-Sep-03          2003.3     25      0.02684&lt;BR /&gt;
               25            1496    30-Sep-04          2004.3     25      0.01826&lt;BR /&gt;
               26            1496    30-Sep-05          2005.3     25      0.06419&lt;BR /&gt;
               27            1496    30-Sep-06          2006.3     25     -0.03246&lt;BR /&gt;
               28            1496    30-Sep-07          2007.3     25      0.00816&lt;BR /&gt;
               29            1496    30-Sep-08          2008.3     25     -0.03550&lt;BR /&gt;
               30            1496    30-Sep-99          1999.3     25      0.08177&lt;BR /&gt;
               31            1496    31-Dec-00          2000.4     25      0.04078&lt;BR /&gt;
               32            1496    31-Dec-01          2001.4     25      0.06475&lt;BR /&gt;
               33            1496    31-Dec-02          2002.4     25      0.02916&lt;BR /&gt;
               34            1496    31-Dec-03          2003.4     25      0.02524&lt;BR /&gt;
               35            1496    31-Dec-04          2004.4     25      0.02744&lt;BR /&gt;
               36            1496    31-Dec-05          2005.4     25     -0.00787&lt;BR /&gt;
               37            1496    31-Dec-06          2006.4     25     -0.09617&lt;BR /&gt;
               38            1496    31-Dec-07          2007.4     25     -0.00332&lt;BR /&gt;
               39            1496    31-Dec-99          1999.4     25      0.06719&lt;BR /&gt;
               40            1496    31-Mar-00          2000.1     25      0.04244&lt;BR /&gt;
               41            1496    31-Mar-01          2001.1     25      0.03444&lt;BR /&gt;
               42            1496    31-Mar-02          2002.1     25      0.04240&lt;BR /&gt;
               43            1496    31-Mar-03          2003.1     25      0.02642&lt;BR /&gt;
               44            1496    31-Mar-04          2004.1     25      0.01729&lt;BR /&gt;
               45            1496    31-Mar-05          2005.1     25      0.02409&lt;BR /&gt;
               46            1496    31-Mar-06          2006.1     25     -0.26155&lt;BR /&gt;
               47            1496    31-Mar-07          2007.1     25      0.02740&lt;BR /&gt;
               48            1496    31-Mar-08          2008.1     25     -0.00994&lt;BR /&gt;
               49            1496    31-Mar-99          1999.1     25      0.07676&lt;BR /&gt;
               50            1992    30-Jun-00          2000.2     24      0.01341&lt;BR /&gt;
               &lt;BR /&gt;
 [/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;SAMPLE:&lt;/B&gt;&lt;BR /&gt;
 [pre]		Obs     dealdate    Acq                                gvkey    id&lt;BR /&gt;
&lt;BR /&gt;
                 1    12DEC2008    International Tech Sys Inc             .     1&lt;BR /&gt;
                 2    09DEC2008    AO Smith Corp                       9771     2&lt;BR /&gt;
                 3    01DEC2008    Johnson &amp;amp; Johnson                   6266     3&lt;BR /&gt;
                 4    24NOV2008    Kratos Defense &amp;amp; Security         126056     4&lt;BR /&gt;
                 5    24NOV2008    Johnson &amp;amp; Johnson                   6266     5&lt;BR /&gt;
                 6    28OCT2008    Clinical Data Inc                   3116     6&lt;BR /&gt;
                 7    27OCT2008    CenturyTel Inc                      2884     7&lt;BR /&gt;
                 8    06OCT2008    Eli Lilly &amp;amp; Co                     65152     8&lt;BR /&gt;
                 9    24SEP2008    Ligand Pharmaceuticals Inc         12495     9&lt;BR /&gt;
                10    22SEP2008    McAfee Inc                         14401    10&lt;BR /&gt;
                11    15SEP2008    Best Buy Co Inc                     2184    11&lt;BR /&gt;
                12    03SEP2008    Park City Group Inc               116166    13&lt;BR /&gt;
                13    02SEP2008    Teradyne Inc                       10453    14&lt;BR /&gt;
                14    22AUG2008    King Pharmaceuticals Inc          112033    16&lt;BR /&gt;
                15    12AUG2008    The Middleby Corp                  13570    17&lt;BR /&gt;
                16    12AUG2008    CVS Caremark Corp                  28654    18&lt;BR /&gt;
                17    07AUG2008    Stream Global Services Inc        178633    19&lt;BR /&gt;
                18    05AUG2008    Planet Hollywood International     62676    20&lt;BR /&gt;
                19    28JUL2008    Sempra Energy Inc                   8272    21&lt;BR /&gt;
                20    21JUL2008    Brocade Commun Sys Inc            120774    22&lt;BR /&gt;
                21    17JUL2008    ON Semiconductor Corp              18914    23&lt;BR /&gt;
                22    16JUL2008    Convergys Corp                    149697    24&lt;BR /&gt;
                23    11JUL2008    Ashland Inc                         1794    26&lt;BR /&gt;
                24    10JUL2008    Access Pharmaceuticals Inc         12713    27&lt;BR /&gt;
                25    10JUL2008    GSI Group Inc                      61356    28&lt;BR /&gt;
                26    09JUL2008    TranSwitch Corp                    60846    29&lt;BR /&gt;
                27    08JUL2008    Eli Lilly &amp;amp; Co                    122895    30&lt;BR /&gt;
                28    26JUN2008    Liberty Media Corp                174168    31&lt;BR /&gt;
                29    23JUN2008    Republic Services Inc             112168    32&lt;BR /&gt;
                30    19JUN2008    TIBCO Software Inc                122061    34&lt;BR /&gt;
                31    09JUN2008    CytRx Corp                         13184    36&lt;BR /&gt;
                32    09JUN2008    Hologic Inc                        65908    37&lt;BR /&gt;
                33    03JUN2008    Smith International Inc             9772    38&lt;BR /&gt;
                34    29MAY2008    Blackbaud Inc                     260893    39&lt;BR /&gt;
                35    28MAY2008    Bristol-Myers Squibb Co           162502    40&lt;BR /&gt;
                36    27MAY2008    Provide Commerce Inc              156415    41&lt;BR /&gt;
                37    16MAY2008    Finisar Corp                      126417    43&lt;BR /&gt;
                38    15MAY2008    CBS Corp                           13714    44&lt;BR /&gt;
                39    13MAY2008    Hewlett-Packard Co                  4537    45&lt;BR /&gt;
                40    12MAY2008    Comtech Telecommun Corp             3358    46&lt;BR /&gt;
                41    08MAY2008    DG FastChannel Inc                 62016    47&lt;BR /&gt;
                42    01MAY2008    Autodesk Inc                        1878    48&lt;BR /&gt;
                43    30APR2008    Stone Energy Corp                  64835    49&lt;BR /&gt;
                44    30APR2008    United Online Inc                 124198    50&lt;BR /&gt;
                45    22APR2008    Medtronic Inc                     178526    51&lt;BR /&gt;
                46    21APR2008    Blue Coat Systems Inc             126615    52&lt;BR /&gt;
                47    15APR2008    Boston Scientific Corp            119214    54&lt;BR /&gt;
                48    14APR2008    Delta Air Lines Inc                 2605    55&lt;BR /&gt;
                49    11APR2008    Cypress Semiconductor Corp         12215    57&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Malek</description>
      <pubDate>Thu, 28 Jan 2010 18:09:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Event-study-and-Date-problem/m-p/48307#M9984</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-01-28T18:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: Event study and Date problem...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Event-study-and-Date-problem/m-p/48308#M9985</link>
      <description>Hi:&lt;BR /&gt;
  Is GVKEY character or numeric? Is it the same in both files? It looks, from this sample of data, as though there are no matches in Universe and Sample. What is the desired treatment for the instances where GVKEY is missing (as you show in OBS 1 in the SAMPLE data? &lt;BR /&gt;
 &lt;BR /&gt;
  Is this the correct logic:&lt;BR /&gt;
If there are fewer than 4 quarters when GVKEY matches will you want ALL the quarters??? If there are more than 4 quarters when GVKEY matches, you only want the 4 quarters before DEAL DATE -- is that INCLUDING the quarter that DEAL DATE is in or the 4 quarters BEFORE DEAL DATE??? For example, if DEAL DATE is Jan 15, 2000, that's 2000.1 -- would you want:&lt;BR /&gt;
Option 1:&lt;BR /&gt;
2009.2, 2009.3, 2009.4 and 2000.1 &lt;BR /&gt;
or&lt;BR /&gt;
Option 2:&lt;BR /&gt;
2009.1, 2009.2, 2009.3 and 2009.4&lt;BR /&gt;
 &lt;BR /&gt;
When you say that DEALDATE is numeric, do you mean that it is a SAS date value. so that if you look at 12DEC2008 without a date format, you see a number like: 17878 (which is how SAS would internally represent 12DEC2008)?&lt;BR /&gt;
&lt;BR /&gt;
What code have you already tried? Have you tried an SQL join? Have you tried a Data step merge? &lt;BR /&gt;
&lt;BR /&gt;
With either approach, if you were going to use any of the SAS date functions to help in your selection, your character date strings would need to be converted to numeric date values (using the INPUT function). Then you could do interval calculations usign the INTNX function. Seeing the code you've tried would be useful -- do you have a preferred method...SQL vs DATA step???&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Thu, 28 Jan 2010 18:36:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Event-study-and-Date-problem/m-p/48308#M9985</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-01-28T18:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: Event study and Date problem...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Event-study-and-Date-problem/m-p/48309#M9986</link>
      <description>I tried a code but I believe it is NOT effecient at all!!&lt;BR /&gt;
Anyway, here it is:&lt;BR /&gt;
&lt;BR /&gt;
First, I created two new variables:&lt;BR /&gt;
1) in &lt;B&gt;UNIVERSE&lt;/B&gt; dataset I created "&lt;I&gt;agvkey_datadate&lt;/I&gt;" which is equal to [(agvkey*100000)+datadate after converted into general number on Excel]&lt;BR /&gt;
2) in SAMPLE dataset I created "&lt;I&gt;agvkey_dealdate&lt;/I&gt;" which is equal to [(agvkey*100000)+dealdate after converted into general number on Excel].&lt;BR /&gt;
&lt;BR /&gt;
Second, I did this code starting by merging as follows:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
*merging UNIVERSE with SAMPLE file;&lt;BR /&gt;
data FINAL;&lt;BR /&gt;
	merge UNIVERSE SAMPLE;&lt;BR /&gt;
	by agvkey;&lt;BR /&gt;
run;&lt;BR /&gt;
*CREATING four separate quarters datasets;&lt;BR /&gt;
*and cleaning the merged file to get the SAMPLE data 1 quarter before dealdate;&lt;BR /&gt;
data SAMPLE_Q1;&lt;BR /&gt;
	set FINAL;&lt;BR /&gt;
	if (agvkey_dealdate-90)&amp;gt;agvkey_datadate then delete;&lt;BR /&gt;
	if agvkey_datadate&amp;gt;agvkey_dealdate then delete;&lt;BR /&gt;
run;&lt;BR /&gt;
*removing duplicates for the near cutoff points in Q1;&lt;BR /&gt;
data SAMPLE_Q1;&lt;BR /&gt;
	set SAMPLE_Q1;&lt;BR /&gt;
	if 	agvkey_datadate=2006437621 or &lt;BR /&gt;
		agvkey_datadate=13760038748 then delete;&lt;BR /&gt;
	run;&lt;BR /&gt;
&lt;BR /&gt;
*cleaning the merged file to get the SAMPLE data 2 quarters before dealdate;&lt;BR /&gt;
data SAMPLE_Q2;&lt;BR /&gt;
	set FINAL;&lt;BR /&gt;
	if (agvkey_dealdate-184)&amp;gt;agvkey_datadate then delete;&lt;BR /&gt;
	if agvkey_datadate&amp;gt;(agvkey_dealdate-90) then delete;&lt;BR /&gt;
	run;&lt;BR /&gt;
*removing Duplicates for the near cutoff points in Q2;&lt;BR /&gt;
data SAMPLE_Q2;&lt;BR /&gt;
	set SAMPLE_Q2;&lt;BR /&gt;
	if 	agvkey_datadate=597336160 or &lt;BR /&gt;
		..........etc&lt;BR /&gt;
		agvkey_datadate=187839386&lt;BR /&gt;
then delete;&lt;BR /&gt;
	run;&lt;BR /&gt;
*cleaning the merged file to get the SAMPLE data 3 quarters before dealdate;&lt;BR /&gt;
data SAMPLE_Q3;&lt;BR /&gt;
	set FINAL;&lt;BR /&gt;
	if (agvkey_dealdate-276)&amp;gt;agvkey_datadate then delete;&lt;BR /&gt;
	if agvkey_datadate&amp;gt;(agvkey_dealdate-182) then delete;&lt;BR /&gt;
	run;&lt;BR /&gt;
*removing Duplicates for the near cutoff points in Q3;&lt;BR /&gt;
data SAMPLE_Q3;&lt;BR /&gt;
	set SAMPLE_Q3;&lt;BR /&gt;
	if 	agvkey_datadate=2254635915  or &lt;BR /&gt;
		.........etc&lt;BR /&gt;
		agvkey_datadate=187839294 &lt;BR /&gt;
			then delete;&lt;BR /&gt;
	run;&lt;BR /&gt;
*cleaning the merged file to get the SAMPLE data 2 quarters before dealdate;&lt;BR /&gt;
data SAMPLE_Q4;&lt;BR /&gt;
	set FINAL;&lt;BR /&gt;
	if (agvkey_dealdate-366)&amp;gt;agvkey_datadate then delete;&lt;BR /&gt;
	if agvkey_datadate&amp;gt;(agvkey_dealdate-273) then delete;&lt;BR /&gt;
	run;&lt;BR /&gt;
*removing Duplicates for the near cutoff points in Q4;&lt;BR /&gt;
data SAMPLE_Q4;&lt;BR /&gt;
	set SAMPLE_Q4;&lt;BR /&gt;
	if 	agvkey_datadate=6263435885 or&lt;BR /&gt;
		............etc&lt;BR /&gt;
		agvkey_datadate=6308039172&lt;BR /&gt;
			then delete;&lt;BR /&gt;
	run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
As you can see, date calculation in this code is faulty and it can bring TWO quarters to some firms which their deal date is around a cutoff point of calendar quarters.&lt;BR /&gt;
&lt;BR /&gt;
Malek</description>
      <pubDate>Thu, 28 Jan 2010 18:38:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Event-study-and-Date-problem/m-p/48309#M9986</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-01-28T18:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: Event study and Date problem...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Event-study-and-Date-problem/m-p/48310#M9987</link>
      <description>Hey,&lt;BR /&gt;
&lt;BR /&gt;
GVKEY is numeric and it is the same in both files. It is a company identifier.&lt;BR /&gt;
&lt;BR /&gt;
There are no matches between the files because I cropped some of the UNIVERSE but here with me a full file contains ALL companies/GVKEYs. While SAMPLE contains ONLY some selected GVKEYs.&lt;BR /&gt;
&lt;BR /&gt;
The logic you are suggesting is "nearly" correct:&lt;BR /&gt;
-If there are fewer than 4 quarters when GVKEY matches will you want ALL the quarters??? &lt;U&gt;IF the quarters older than dealdate&lt;/U&gt;. &lt;BR /&gt;
-If there are more than 4 quarters when GVKEY matches, you only want the 4 quarters before DEAL DATE. &lt;U&gt;YES that's correct&lt;/U&gt;.&lt;BR /&gt;
- and this is EXCLUDING the quarter of the deal date. &lt;BR /&gt;
For example: if DEAL DATE is Jan 15 2000, that's 2000.1 then I need the data that have DATA DATE:&lt;BR /&gt;
 1999.4, 1999.3, 1999.2, 1999.1.&lt;BR /&gt;
&lt;BR /&gt;
DEALDATE is numeric as a SAS date format (DATE9.).&lt;BR /&gt;
&lt;BR /&gt;
The code I tried is posted up already. (the stupid and ineffecient one!).&lt;BR /&gt;
&lt;BR /&gt;
I prefer DATA step because I'm a beginner on SAS.&lt;BR /&gt;
&lt;BR /&gt;
Loads of thanks&lt;BR /&gt;
Malek.</description>
      <pubDate>Thu, 28 Jan 2010 18:53:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Event-study-and-Date-problem/m-p/48310#M9987</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-01-28T18:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: Event study and Date problem...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Event-study-and-Date-problem/m-p/48311#M9988</link>
      <description>Hi:&lt;BR /&gt;
  I believe that your approach might make a few more passes through the data than is automatically necessary. Let's deal with some "dummy" data. For example, if you had a file like this, you could easily see which 4 observations to "grab" for each GVKEY. In the fake data below, I made some dummy deal dates:&lt;BR /&gt;
[pre]&lt;BR /&gt;
    gvkey     dealdate      obsdate    qtrdeal    qtrobs    status    gotone&lt;BR /&gt;
                         &lt;BR /&gt;
     1235    31OCT1999    30SEP1999    1999.4     1999.3      LT         1&lt;BR /&gt;
     1235    31OCT1999    30JUN1999    1999.4     1999.2      LT         2&lt;BR /&gt;
     1235    31OCT1999    31MAR1999    1999.4     1999.1      LT         3&lt;BR /&gt;
**********************************************************************************&lt;BR /&gt;
     1278    15OCT2000    30SEP2000    2000.4     2000.3      LT         1&lt;BR /&gt;
     1278    15OCT2000    30JUN2000    2000.4     2000.2      LT         2&lt;BR /&gt;
     1278    15OCT2000    31MAR2000    2000.4     2000.1      LT         3&lt;BR /&gt;
     1278    15OCT2000    31DEC1999    2000.4     1999.4      LT         4&lt;BR /&gt;
     1278    15OCT2000    30SEP1999    2000.4     1999.3      LT         5&lt;BR /&gt;
     1278    15OCT2000    30JUN1999    2000.4     1999.2      LT         6&lt;BR /&gt;
     1278    15OCT2000    31MAR1999    2000.4     1999.1      LT         7&lt;BR /&gt;
**********************************************************************************&lt;BR /&gt;
     1496    15SEP2006    30SEP2008    2006.3     2008.3      GT         0&lt;BR /&gt;
     1496    15SEP2006    30JUN2008    2006.3     2008.2      GT         0&lt;BR /&gt;
     1496    15SEP2006    31MAR2008    2006.3     2008.1      GT         0&lt;BR /&gt;
     1496    15SEP2006    31DEC2007    2006.3     2007.4      GT         0&lt;BR /&gt;
     1496    15SEP2006    30SEP2007    2006.3     2007.3      GT         0&lt;BR /&gt;
     1496    15SEP2006    30JUN2007    2006.3     2007.2      GT         0&lt;BR /&gt;
     1496    15SEP2006    31MAR2007    2006.3     2007.1      GT         0&lt;BR /&gt;
     1496    15SEP2006    31DEC2006    2006.3     2006.4      GT         0&lt;BR /&gt;
     1496    15SEP2006    30SEP2006    2006.3     2006.3      EQ         0&lt;BR /&gt;
     1496    15SEP2006    30JUN2006    2006.3     2006.2      LT         1&lt;BR /&gt;
     1496    15SEP2006    31MAR2006    2006.3     2006.1      LT         2&lt;BR /&gt;
     1496    15SEP2006    31DEC2005    2006.3     2005.4      LT         3&lt;BR /&gt;
     1496    15SEP2006    30SEP2005    2006.3     2005.3      LT         4&lt;BR /&gt;
     1496    15SEP2006    30JUN2005    2006.3     2005.2      LT         5&lt;BR /&gt;
     1496    15SEP2006    31MAR2005    2006.3     2005.1      LT         6&lt;BR /&gt;
.... more observations for GVKEY 1496 ....&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
I believe that if the UNIVERSE data is sorted in descending order and you create some extra variables, you can create this type of file with one merge.&lt;BR /&gt;
&lt;BR /&gt;
The program below uses your UNIVERSE data, but creates some SAMPLE data designed to match only 1235, 1278 and 1496.&lt;BR /&gt;
 &lt;BR /&gt;
Then, in the MERGE step, the merge is done using IN= special variables, this allows a test to be done to make sure that any observation has a match in both files. When you are doing a one to many merge, or you need to control the creation of variables or the selective output of rows, using the IN= variables can be extremely useful.&lt;BR /&gt;
&lt;BR /&gt;
You can create 2 new variables -- one that represents the quarter of the dealdate and one that represents the quarter of the obs date. By comparing those 2 dates, you easily know whether the observation date quarter  is GT the deal date quarter (you do not want this one); whether the observation date quarter is EQ the deal date quarter (you do not want this one); or whether the observation date is LT the deal date quarter (you only want 4 of these -- but the most recent 4 -- which is why you sort the UNIVERSE data in descending order. &lt;BR /&gt;
&lt;BR /&gt;
In order to get the most recent 4 quarters, you only need to set up a counter variable (GOTONE in my program). At the first of every group, or the FIRST.GVKEY, you set GOTONE to 0. Then you only need to increment GOTONE when the quarter of the obs date is LT the quarter of the deal date.&lt;BR /&gt;
&lt;BR /&gt;
You can control the output of observations with an IF statement, by testing that the value of GOTONE has to be 1,2,3 or 4 in order to qualify for OUTPUT. At this point in the program, you already know 2 things:&lt;BR /&gt;
1) this particular observation matched in both files (because it passed the IN= test)&lt;BR /&gt;
and&lt;BR /&gt;
2) you have an observation where quarter of obs date is LT quarter of deal date (with obs date sorted in descending order)&lt;BR /&gt;
 &lt;BR /&gt;
You might need to tweak the logic of this a bit when you use real data for SAMPLE instead of fake data. The final MERGE creates 2 datasets -- the ALLMATCH dataset is the one shown above -- you can use this for verifying that the logic is correct for your real data. the ONLY4QTR dataset contains only the 4 quarters.&lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
  &lt;BR /&gt;
options nodate nonumber nocenter;&lt;BR /&gt;
                      &lt;BR /&gt;
data UNIVERSE;&lt;BR /&gt;
  length datadate $9.; &lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input gvkey datadate $ datacqtr $ sic2 lag4_roa;&lt;BR /&gt;
  obsdate = input(datadate,anydtdte.);&lt;BR /&gt;
  format obsdate date9.;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1235  30-Jun-99 1999.2 22  0.01534&lt;BR /&gt;
1235  30-Sep-99 1999.3 22  0.02700&lt;BR /&gt;
1235  31-Mar-99 1999.1 22  0.01663&lt;BR /&gt;
1278  30-Jun-00 2000.2 23 -0.01379&lt;BR /&gt;
1278  30-Jun-99 1999.2 23 -0.09581&lt;BR /&gt;
1278  30-Sep-00 2000.3 23 -0.01427&lt;BR /&gt;
1278  30-Sep-99 1999.3 23 -0.05392&lt;BR /&gt;
1278  31-Dec-99 1999.4 23 -0.09128&lt;BR /&gt;
1278  31-Mar-00 2000.1 23 -0.01787&lt;BR /&gt;
1278  31-Mar-99 1999.1 23 -0.01613&lt;BR /&gt;
1496  30-Jun-00 2000.2 25  0.06021&lt;BR /&gt;
1496  30-Jun-01 2001.2 25  0.05269&lt;BR /&gt;
1496  30-Jun-02 2002.2 25  0.05435&lt;BR /&gt;
1496  30-Jun-03 2003.2 25  0.02923&lt;BR /&gt;
1496  30-Jun-04 2004.2 25  0.02190&lt;BR /&gt;
1496  30-Jun-05 2005.2 25  0.01718&lt;BR /&gt;
1496  30-Jun-06 2006.2 25 -0.01955&lt;BR /&gt;
1496  30-Jun-07 2007.2 25  0.00963&lt;BR /&gt;
1496  30-Jun-08 2008.2 25 -0.00479&lt;BR /&gt;
1496  30-Jun-99 1999.2 25  0.08410&lt;BR /&gt;
1496  30-Sep-00 2000.3 25  0.03563&lt;BR /&gt;
1496  30-Sep-01 2001.3 25  0.03606&lt;BR /&gt;
1496  30-Sep-02 2002.3 25  0.02185&lt;BR /&gt;
1496  30-Sep-03 2003.3 25  0.02684&lt;BR /&gt;
1496  30-Sep-04 2004.3 25  0.01826&lt;BR /&gt;
1496  30-Sep-05 2005.3 25  0.06419&lt;BR /&gt;
1496  30-Sep-06 2006.3 25 -0.03246&lt;BR /&gt;
1496  30-Sep-07 2007.3 25  0.00816&lt;BR /&gt;
1496  30-Sep-08 2008.3 25 -0.03550&lt;BR /&gt;
1496  30-Sep-99 1999.3 25  0.08177&lt;BR /&gt;
1496  31-Dec-00 2000.4 25  0.04078&lt;BR /&gt;
1496  31-Dec-01 2001.4 25  0.06475&lt;BR /&gt;
1496  31-Dec-02 2002.4 25  0.02916&lt;BR /&gt;
1496  31-Dec-03 2003.4 25  0.02524&lt;BR /&gt;
1496  31-Dec-04 2004.4 25  0.02744&lt;BR /&gt;
1496  31-Dec-05 2005.4 25 -0.00787&lt;BR /&gt;
1496  31-Dec-06 2006.4 25 -0.09617&lt;BR /&gt;
1496  31-Dec-07 2007.4 25 -0.00332&lt;BR /&gt;
1496  31-Dec-99 1999.4 25  0.06719&lt;BR /&gt;
1496  31-Mar-00 2000.1 25  0.04244&lt;BR /&gt;
1496  31-Mar-01 2001.1 25  0.03444&lt;BR /&gt;
1496  31-Mar-02 2002.1 25  0.04240&lt;BR /&gt;
1496  31-Mar-03 2003.1 25  0.02642&lt;BR /&gt;
1496  31-Mar-04 2004.1 25  0.01729&lt;BR /&gt;
1496  31-Mar-05 2005.1 25  0.02409&lt;BR /&gt;
1496  31-Mar-06 2006.1 25 -0.26155&lt;BR /&gt;
1496  31-Mar-07 2007.1 25  0.02740&lt;BR /&gt;
1496  31-Mar-08 2008.1 25 -0.00994&lt;BR /&gt;
1496  31-Mar-99 1999.1 25  0.07676&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
              &lt;BR /&gt;
** sort by descending obsdate so most current obsdate is first;&lt;BR /&gt;
proc sort data=universe;&lt;BR /&gt;
  by gvkey descending obsdate;&lt;BR /&gt;
run;&lt;BR /&gt;
                  &lt;BR /&gt;
** show observations (might want to limit this proc print if a big file;&lt;BR /&gt;
ods listing;&lt;BR /&gt;
proc print data=universe;&lt;BR /&gt;
  title 'Universe Companies OBSDATE is character DATADATE converted to numeric';&lt;BR /&gt;
run;&lt;BR /&gt;
                   &lt;BR /&gt;
** read sample data;&lt;BR /&gt;
** note that dealdate for 1496 is not at the beginning of the range;&lt;BR /&gt;
** for the fake observations for this company;&lt;BR /&gt;
data SAMPLE;&lt;BR /&gt;
  length acq $50;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input dealdate : date9. acq $ gvkey id;&lt;BR /&gt;
  format dealdate date9.;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
31Oct1999    AAAAAAAAAAAAA           1235     2&lt;BR /&gt;
15OCT2000    BBBBBBBBBBBBB           1278     3&lt;BR /&gt;
15SEP2006    CCCCCCCCCCCCC           1496     4&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
             &lt;BR /&gt;
proc sort data=sample;&lt;BR /&gt;
  by gvkey dealdate;&lt;BR /&gt;
run;&lt;BR /&gt;
                  &lt;BR /&gt;
proc print data=sample;&lt;BR /&gt;
  title 'Sample Companies To Find in UNIVERSE';&lt;BR /&gt;
run;&lt;BR /&gt;
                            &lt;BR /&gt;
** Create 2 datasets -- one for all obs that match (ALLMATCH);&lt;BR /&gt;
** and one for only the 4 qtr obs (ONLY4QTR) before the DEALDATE;&lt;BR /&gt;
data allmatch only4qtr;&lt;BR /&gt;
  retain gotone 0;&lt;BR /&gt;
  length qtrdeal qtrobs $8.;&lt;BR /&gt;
  merge sample(in=ins) universe(in=inu);&lt;BR /&gt;
  by gvkey;&lt;BR /&gt;
  ** Subsetting IF only "passes" obs which match in both files;&lt;BR /&gt;
  ** to rest of program logic;&lt;BR /&gt;
  if (ins and inu);&lt;BR /&gt;
                                &lt;BR /&gt;
  ** make a quarter variable for dealdate and obsdate;&lt;BR /&gt;
  qtrdeal = put(dealdate,yyqp7.);&lt;BR /&gt;
  qtrobs = put(obsdate,yyqp7.);&lt;BR /&gt;
  ** for first gvkey obs, set gotone variable to 0;&lt;BR /&gt;
  if first.gvkey then do;&lt;BR /&gt;
     gotone = 0;&lt;BR /&gt;
  end;&lt;BR /&gt;
  ** if qtr of obs is LT qtr of deal, then increment gotone;&lt;BR /&gt;
  ** remember that obs data is in descending order;&lt;BR /&gt;
  if qtrobs lt qtrdeal then gotone + 1;&lt;BR /&gt;
                 &lt;BR /&gt;
  ***** for verification purposes only;&lt;BR /&gt;
  ** do not need this section of code, after you verify that the logic;&lt;BR /&gt;
  ** works correctly. Also, do not need ALLMATCH data -- that is for;&lt;BR /&gt;
  ** verification purposes, too.;&lt;BR /&gt;
  if qtrobs lt qtrdeal then status='LT';&lt;BR /&gt;
  else if qtrobs eq qtrdeal then status = 'EQ';&lt;BR /&gt;
  else if qtrobs gt qtrdeal then status = 'GT';&lt;BR /&gt;
  output allmatch;&lt;BR /&gt;
  ***** for verification purposes only;&lt;BR /&gt;
                        &lt;BR /&gt;
  ** only want the 4 obs where qtr of obsdate is lt qtr of dealdate;&lt;BR /&gt;
  if 1 le gotone le 4 then output only4qtr;&lt;BR /&gt;
run;&lt;BR /&gt;
                      &lt;BR /&gt;
options ls=100;&lt;BR /&gt;
proc print data=allmatch;&lt;BR /&gt;
  title 'Match in Both Files, but have ALL OBS';&lt;BR /&gt;
  title2 'look at pattern for qtrdeal and qtrobs variables and value of GOTONE';&lt;BR /&gt;
  var gvkey dealdate obsdate qtrdeal qtrobs status gotone ;&lt;BR /&gt;
  format dealdate obsdate date9.;&lt;BR /&gt;
run;&lt;BR /&gt;
                     &lt;BR /&gt;
proc print data=only4qtr;&lt;BR /&gt;
  title 'Match in Both Files, but only 4 quarters before merger';&lt;BR /&gt;
  title2 'This works because the Universe file is in descending order';&lt;BR /&gt;
  title3 'And you only get the values for GOTONE between 1 and 4';&lt;BR /&gt;
  var gvkey dealdate obsdate qtrdeal qtrobs gotone acq id datacqtr sic2 lag4_roa;&lt;BR /&gt;
  format dealdate obsdate date9.;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Fri, 29 Jan 2010 21:10:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Event-study-and-Date-problem/m-p/48311#M9988</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-01-29T21:10:50Z</dc:date>
    </item>
  </channel>
</rss>

