Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"S.H. Former" <S.H.Former@uvt.nl> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: creating new variable |

Date |
Wed, 12 Oct 2011 18:17:48 +0200 |

Dear reader, I have a question regarding the composition of my database. I want to know whether it is possible to incorporate the following variable. I want to create a variable that counts previous observations but only till five years back. Let me explain it using a part my database which looks as follows: gvkey appyear 1004 1985 1004 2001 1010 1977 1010 1977 1010 1977 1010 1977 1010 1977 1010 1977 1010 1977 1010 1978 1010 1978 1010 1978 1010 1978 1010 1978 1010 1978 1010 1978 1010 1978 1010 1978 1010 1978 1010 1978 1010 1979 1010 1979 1010 1979 1010 1979 1010 1979 1010 1979 1010 1979 1010 1979 1010 1979 Now I want a new variable that counts the number of observations for each Gvkey (so it has to be counted for each Gvkey) where the number of observations is counted until five years back. So the new variable should look like this: gvkey appyear New Variable Comment 1004 1985 0 no observations before 1004 2001 0 longer than five years ago 1010 1977 0 no observations 1010 1977 0 no observations 1010 1977 0 no observations 1010 1977 0 no observations 1010 1977 0 no observations 1010 1977 0 no observations 1010 1977 0 no observations 1010 1978 7 number of observations in 1977 by Gvkey 1010 1010 1978 7 number of observations in 1977 by Gvkey 1010 1010 1978 7 number of observations in 1977 by Gvkey 1010 1010 1978 7 number of observations in 1977 by Gvkey 1010 1010 1978 7 number of observations in 1977 by Gvkey 1010 1010 1978 7 number of observations in 1977 by Gvkey 1010 1010 1978 7 number of observations in 1977 by Gvkey 1010 1010 1978 7 number of observations in 1977 by Gvkey 1010 1010 1978 7 number of observations in 1977 by Gvkey 1010 1010 1978 7 number of observations in 1977 by Gvkey 1010 1010 1978 7 number of observations in 1977 by Gvkey 1010 1010 1979 18 number of observation in 1977 and 1978 by Gvkey 1010 1010 1979 18 number of observation in 1977 and 1978 by Gvkey 1010 1010 1979 18 number of observation in 1977 and 1978 by Gvkey 1010 1010 1979 18 number of observation in 1977 and 1978 by Gvkey 1010 1010 1979 18 number of observation in 1977 and 1978 by Gvkey 1010 1010 1979 18 number of observation in 1977 and 1978 by Gvkey 1010 1010 1979 18 number of observation in 1977 and 1978 by Gvkey 1010 1010 1979 18 number of observation in 1977 and 1978 by Gvkey 1010 1010 1979 18 number of observation in 1977 and 1978 by Gvkey 1010 Of course, the comment would not have to be included but is to make the problem clear to you! Hope you can help me, Kind regards, Sytze * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: creating new variable***From:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**Re: st: how to specify the decimals for output** - Next by Date:
**Re: Re: st: Regression Discontinuity Design** - Previous by thread:
**st: how to specify the decimals for output** - Next by thread:
**Re: st: creating new variable** - Index(es):