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

AW: st: Date: Sat, 7 Dec 2002 15:35:59 +0100


From   "Sophie Barthel" <[email protected]>
To   <[email protected]>
Subject   AW: st: Date: Sat, 7 Dec 2002 15:35:59 +0100
Date   Sat, 7 Dec 2002 17:57:00 +0100

Dear Erik

thank you very much.

One question regarding the running code: will that only count progid when it
takes on the value 0 as that is what I need?

Do I have to add something along the lines of else y = 0  so that in all the
cases where progid is not equal to 1 and in the case where the number of 0
entries has exceeded 200, y will take the value 0?

basically my next step would then be to say

stset progtm, failure(y)

Yours

Sophie

-----Urspr�ngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]]Im Auftrag von Erik �.
S�rensen
Gesendet: Samstag, 7. Dezember 2002 16:53
An: [email protected]
Betreff: Re: st: Date: Sat, 7 Dec 2002 15:35:59 +0100


On l�rdag, des 7, 2002, at 10:35 America/Montreal, Sophie Barthel wrote:

> i have currently got a variable which can take the values 1 or 0. i
> want to create a new variable which takes the values of the old one
> but which will be equal to 0 once the number of 0 values in the old
> variable exceeds 200.
>
> the code i have used is

. bys progid: gen np = _n
. gen byte y = (progid==1 & np <= 200)
. drop np

Probably you would like to do the "bys progid" with some other variable
as well, such as personal id or whatever. The idea is that you sort on
the progid, and takes a running count within the progid (or possibly
'progid pid') group, and  generates y as 1 only if progid is 1 and the
running number is less than or equal to 200. I am not sure I understand
the syntax of what you proposed. Does Stata accept it?

best regards
Erik
--
Erik �. S�rensen,  <http://www.geocities.com/erik_oiolf/>.
phd student (economics), Norwegian School of Economics.
currently visiting Queen's University, Kingston, Ontario.

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