Bookmark and Share

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]

st: Count the number of changing string values


From   Ching Wong <ching.y.wong@student.adelaide.edu.au>
To   statalist@hsphsun2.harvard.edu
Subject   st: Count the number of changing string values
Date   Fri, 14 Jun 2013 18:50:43 +0930

Hi,

I have the following data set:

Id     sex   drug1999   drug2000    drug2001      drug 2001

1       F       Yes            No          Yes            Unknown

3       M       No           Yes          Yes             No

5      F         Yes          Yes          Yes            Yes

9      M       Unknown    Yes          No             Yes

10     F        Yes           No           Yes             No

I would like to produce a count of to show the number of people who
quit each year, only count the first time they quit and do not care if
they change their status to ‘No’ again.

What would be the command? I tried to change it to the long formal and
use the lag function, but it doesn’t work.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index