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

st: Check existence within a group


From   "de la Garza, Adrian" <[email protected]>
To   <[email protected]>
Subject   st: Check existence within a group
Date   Fri, 7 May 2004 09:15:29 -0400

I have a database that contains info on bonds issued as follows:

borrower	issuedate	mtydate	amount	mkttype
ABN Amro	04Jun93	03Jun98	50		E
ABN Amro	19Sep94	17Jul96	100		E
ABN Amro	22Nov94	21Nov98	50		S
...
ACINDAR	02Feb92	30Jan99	200		L
ACINDAR	20Mar92	19Mar97	50		E
ACINDAR	29Jul94	28Mar00	175		L
...

and I want to create a variable -newmkttype- that tells me if the
borrower is issuing a bond in a completely new and unknown market type.
If it is, then I want this variable to take the value of 0. If, on the
contrary, the borrower has issued bonds in this market type in the past,
then I want this variable to take the value of 1 (notice that the
database is sorted by borrower issuedate mtydate amount).

borrower	issuedate	mtydate	amount	mkttype	newmkttype
ABN Amro	04Jun93	03Jun98	50		E		0
ABN Amro	19Sep94	17Jul96	100		E		1
ABN Amro	22Nov94	21Nov98	50		S		0
...
ACINDAR	02Feb92	30Jan99	200		L		0
ACINDAR	20Mar92	19Mar97	50		E		0
ACINDAR	29Jul94	28Mar00	175		L		1
...

How can I construct this variable? Is there an easy way of checking the
borrower's history to determine whether -newmkttype- should get a 0 or a
1, without writing a complicated loop?

Thank you very much.
Adrian

*
*   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