Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Nick: RE: Programing question


From   "Penalva, Fernando" <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: Nick: RE: Programing question
Date   Tue, 15 Apr 2003 13:30:27 +0200

Title: Nick: RE: Programing question

Nick,
        Thanks for your prompt reply. I already merged my two datasets. However, I don't know how to run a regression of Y on X for each FIRMID and ENDDATE so that each regression uses as observations the current observation and the previous 60 within the FIRMID group. On top of that I want to store the coefficient on X for each regression.

-----Original Message-----
From: Nick Cox [mailto:[email protected]]
Sent: Monday, April 14, 2003 12:34 PM
To: [email protected]
Subject: st: RE: Programing question


Penalva, Fernando

> I need to program a function or macro that does the following:
> I have two datasets: Dataset1 contains two variables: FIRMID
> (numeric format) and ENDDATE (date format YYYMMDD). Dataset2
> contains four variables: FIRMID (numeric format), DATE (date
> format YYYYMMDD) Y and X.

> I want to add a new variable, COEFF, to each observation in
> Dataset1. To create COEFF, I have to take observations in
> Dataset2 with the same FIRMID, and DATE  between (ENDATE
> minus 2 years) and ENDATE. With the selected observations
> I will regress Y on X. COEFF will be the coefficient
> on the X variable.

You shouldn't need to do any programming.

You need to -merge- your files first
and work with the merged file, carefully
-save-d.

Then there are various ways to do it.
Perhaps -statsby- and another -merge.

Nick
[email protected]
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index