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]

Re: st: drop range of variables meeting condition in another variable


From   Rebecca Pope <[email protected]>
To   [email protected]
Subject   Re: st: drop range of variables meeting condition in another variable
Date   Mon, 18 Mar 2013 21:14:17 -0500

Tamer,
You have misunderstood Nick's code. You are not meant to replace
"varlist" in `r(varlist)' yourself. r(varlist) is a returned value of
the program -findname-. When you type -drop `r(varlist)'- after
-findname-, Stata will expand that local macro with the names of the
variables that met your specified condition, all(@==0).

With respect to your question about a 2nd condition, the -findname-
help file indicates that you may specify -if- conditions. Therefore:

findname gene* if case==1, all(@==0)

will find variable names where the no cases have that gene cluster but
the cluster may still exist among controls.

You can see a test case using data designed to have all 0s for
odd-numbered genes among cases only:
**begin example **
clear
version 12

set obs 100
gen case = _n<=50

forvalues i=1/6 {
gen gene`i' = max(0,(-(ceil(`i'/2)-floor(`i'/2))*case)+round(runiform()))
}

findname gene*, all(@==0)

findname gene* if case==1, all(@==0)
** end example **

You'll see the 1st -findname- returns no variable names but the 2nd
returns gene1, gene3, and gene5. With 14,000 genes, I assume that
you'll have at least some variables that meet your criteria. However,
you may want to use -capture drop `r(varlist)'-, just in case
-findname- doesn't find any eligible variables.

Note also that you must open your single quotations with ` not '. I
don't know if your e-mail editor "helpfully" changed that before you
posted or if the error exists in your code.

Regards,
Rebecca
*
*   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