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: generate rolling proportions with foreach using an MI dataset
From
Tim Evans <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
st: generate rolling proportions with foreach using an MI dataset
Date
Wed, 2 Nov 2011 13:18:06 +0000
I am trying to obtain proportions of a variable over time using an MI dataset in Stata 11.2, this I achieve using:
mim: proportion stage if _mj>0, over(year)
However, each single year does not contain as many cases as I would like, so I would like to combine 5 years of data for eahc data point like:
1985-1989
1986-1990
1987-1991
1988-1992
and so on. I've tried to do this with a foreach loop but cant seem to get it to work, I'd appreciate any advice.
Current code:
forvalues startyear=1985(1)2005 {
mim: proportion stage if _mj>0 & inrange(year,`startyear',`startyear'+4), over(`startyear')
}
This is the output:
. forvalues startyear=1985(1)2005 {
2. mim: proportion stage if _mj>0 & inrange(year,`startyear',`startyear'+4), over(`startyear')
3.
. }
[note: using ice-style format variables _mi and _mj]
-> _mj==1
-> proportion stage if _mj>0 & inrange(year,1985,1985+4), over(1985)
1985 invalid name
invalid over() option
r(198);
_DISCLAIMER:
This email and any attachments hereto contains proprietary information, some or all of which may be confidential or legally privileged. It is for the exclusive use of the intended recipient(s) only. If an addressing or transmission error has misdirected this e-mail and you are not the intended recipient(s), please notify the author by replying to this e-mail. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this e-mail or any attachments, as this may be unlawful.
*
* 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/