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: Fwd: Nested Foreach Comparing too Many Variables


From   William Sankey <wsankey@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Fwd: Nested Foreach Comparing too Many Variables
Date   Fri, 22 Mar 2013 04:57:15 -0500

I am running the following nested foreach and am afraid I am comparing
too many things:

local DIAG "Diagnosis1 Diagnosis2 Diagnosis3 Diagnosis4 Diagnosis5"
local SEV "Severity1 Severity2 Severity3 Severity4 Severity5"

        foreach X of varlist `DIAG' {
                    foreach Y of varlist `SEV' {
        replace  complex_severity=1 if
inlist(`X',"710","714","715","720","725","733") & (`Y'>=2  & `Y' !=.)
        }
        }

I would like to compare Diagnosis1 with Severity1 but fear the code is
comparing Diagnosis1 with every severity level.

Could you recommend a better way of achieving the goal; something
along the lines of a different array?

Thanks,
Will Sankey

--
William J. Sankey
Johns Hopkins University
MA Public Policy '12



--
William J. Sankey
Johns Hopkins University
MA Public Policy '12
*
*   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