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

st: Nick: RE: Programing question

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

Title: Nick: RE: Programing question

        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 []
Sent: Monday, April 14, 2003 12:34 PM
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

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

*   For searches and help try:
*   For searches and help try:

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