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]

From |
Tim Evans <Tim.Evans@wmciu.nhs.uk> |

To |
"'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: RE: RE: generate rolling proportions with foreach using an MI dataset |

Date |
Wed, 2 Nov 2011 14:18:25 +0000 |

As the foreach loop was taking a very long time to run (I have 1.8m observations after mi) I thought I would see if Maartens suggestion was quicker. However, this doesn't give me the proportions for the following time frames: 1985-1989 1986-1990 1987-1991 1988-1992 rather it gives me 1985-1989 1990-1994 1995-1999 and so on, thus missing out the year ranges in between. Assuming that the foreach loop is the way to go forward, how can I extract the results into a stata data file? Currently I have a very large log file to extract the proportions and CIs from. Best wishes Tim -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Tim Evans Sent: 02 November 2011 14:06 To: 'statalist@hsphsun2.harvard.edu' Subject: st: RE: RE: generate rolling proportions with foreach using an MI dataset Hi Nick, Maarten, Thanks for your comments, I was just about to post back saying I had a solution. The problem I have with the inrange() and removing over() options is that when the results are returned, they are poorly labelled so its hard to know which is which (OK you can guess that first table relates to the first period, but its not clear). So when I removed the over() option I inserted text for each rolling proportion to allow me to see which was which: forvalues startyear=1985(1)2005 { di as text "`startyear'" "-" "`startyear'+4" mim: proportion grade if _mj>0 & inrange(yydx,`startyear',`startyear'+4): } Best wishes Tim -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox Sent: 02 November 2011 13:27 To: 'statalist@hsphsun2.harvard.edu' Subject: st: RE: generate rolling proportions with foreach using an MI dataset The -over()- option of -proportion- expects a varlist, namely variable name(s). 1985 is not a variable name. This is nothing to do with imputation, looping or rolling. The error message points directly to the error. But I don't see that you need to specify -over()- at all. Your -inrange()- option is designed to give you rolling. Nick n.j.cox@durham.ac.uk Tim Evans 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); * * 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/ _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/ _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/

**References**:**re: st: arega and post regression tests***From:*Christopher Baum <kit.baum@bc.edu>

**RE: st: arega and post regression tests***From:*Ozgur Ozdemir <ozdemirozgur@hotmail.com>

**RE: st: arega and post regression tests***From:*Nick Cox <n.j.cox@durham.ac.uk>

**RE: st: arega and post regression tests***From:*Ozgur Ozdemir <ozdemirozgur@hotmail.com>

**st: generate rolling proportions with foreach using an MI dataset***From:*Tim Evans <Tim.Evans@wmciu.nhs.uk>

- Prev by Date:
**st: Mean within- and between-cluster distances after sqom and sqclusterdat** - Next by Date:
**Re: st: binormal approximation** - Previous by thread:
**st: RE: RE: generate rolling proportions with foreach using an MI dataset** - Next by thread:
**re: RE: st: arega and post regression tests** - Index(es):