Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: working with a 24-character string variable consisting of 0s and 1s


From   Lisa Cook <hlthsrvcsphd@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: working with a 24-character string variable consisting of 0s and 1s
Date   Mon, 10 Feb 2014 21:46:05 -0500

Hi,

I need help working with a cumbersome string variable. I'm using Stata/MP 13.0.

I've inherited a dataset that includes several variables indicating
the number of months each person had specific kinds of health
insurance (Medicaid, Medicare, private, etc.).

The variables are 24 characters long in string format. Each character
is either a 0 or 1, and represents whether the person had coverage in
that month. So, if one of these variables equals
"000000000000000000000000", the person had no coverage in any month of
that type, while if it equals "111111111111111111111111", they were
covered in every month by that kind of insurance. If the variable
equals, say, "101111111111111111111111", the person had 23 months of
coverage, but no coverage in the 2nd month.

I would like to use these variables to generate, for each kind of
insurance, the total in year 1, the total in year 2, and the total
number of months of coverage in both years.

I've used regexm before, but I can't figure out how to apply that code
to my situation. I'd be very grateful if anyone could suggest some
options.

Thanks so much,
Lisa
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index