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 at the end of May, and its replacement, statalist.org is already up and running.


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

st: code skips based on conditions


From   "Darren White" <darrenm.white@health.qld.gov.au>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: code skips based on conditions
Date   Thu, 28 Mar 2013 13:28:56 +1000

Hi Statalisters

I am running some foreach tabulate loops the results of which are accumulat ed by matrix commands. (see code below).
 I would like skip (at the point *** in the code) to the next level of local levels based on a conditional test of the number
of observations contained in the scalar e(N) which is returned after each tabulated combination of the foreach variables.
Have not been able to find anything (or even a lead) that could help me do this.

Any suggestions or ideas of how to go about this would be much appreciated.

thanks
Darren

levelsof lga08_code, local(levels)
foreach l of local levels {
foreach var of varlist  good_srh  satisfied_hlth{
foreach strat of varlist persons rsex agecat_4cat agecat_nhs  agecat_4cat_male  agecat_4cat_female agecat_nhs_m agecat_nhs_f aria_plus_cats quint_pos_weighted {
svy:tab `strat' `var' if lga08_code=3D=3D`l' & agecat_nhs>50 , row se
//extracting necessary scalars and calculations from the matrix output list

****Insertion of condition to skip to next level based on value of scalar e(N)
scalar g=3D`l'

scalar Ppn=3De(N_pop)
scalar Ndenom=3De(N_psu)
scalar def=3De(df_r)
scalar r=3De(r)
matrix c=3De(c)
matrix rt=3Dr*c
scalar rtot=3Drt[1,1]
//Matices with constant values across the tabulation
matrix temp=3DJ(rtot,1,1)
matrix wtdPn=3DPpn*temp
matrix df=3Ddef*temp
matrix geog=3Dg*temp
matrix N=3DNdenom*temp etc etc etc....


********************************************************************************
This email, including any attachments sent with it, is confidential and for the sole use of the intended recipient(s). This confidentiality is not waived or lost, if you receive it and you are not the intended recipient(s), or if it is transmitted/received in error.
Any unauthorised use, alteration, disclosure, distribution or review of this email is strictly prohibited.  The information contained in this email, including any attachment sent with it, may be subject to a statutory duty of confidentiality if it relates to health service matters.
If you are not the intended recipient(s), or if you have received this email in error, you are asked to immediately notify the sender by telephone collect on Australia +61 1800 198 175 or by return email.  You should also delete this email, and any copies, from your computer system network and destroy any hard copies produced.
If not an intended recipient of this email, you must not copy, distribute or take any action(s) that relies on it; any form of disclosure, modification, distribution and/or publication of this email is also prohibited.
Although Queensland Health takes all reasonable steps to ensure this email does not contain malicious software, Queensland Health does not accept responsibility for the consequences if any person's computer inadvertently suffers any disruption to services, loss of information, harm or is infected with a virus, other malicious computer programme or code that may occur as a consequence of receiving this email.
Unless stated otherwise, this email represents only the views of the sender and not the views of the Queensland Government.
**********************************************************************************


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