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   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: drop range of variables meeting condition in another variable
Date   Mon, 18 Mar 2013 20:26:35 +0000

Last line should be

drop `todrop'

Nick

On Mon, Mar 18, 2013 at 8:02 PM, Nick Cox <[email protected]> wrote:
> At a guess, you want to -drop- all gene variables that are identically
> zero. That is
>
> findname gene*, all(@==0)
>
> drop `r(varlist)'
>
> where -findname- is to be found by -search findname- and downloaded
> from the Stata Journal files.
>
> It is not so difficult without -findname-, either.
>
> foreach v of var gene* {
>        su `v', meanonly
>        if r(max) == 0 local todrop `todrop' `v'
> }
> drop `v'
>
> Nick
>
> On Mon, Mar 18, 2013 at 7:53 PM, Tamer Farag
> <[email protected]> wrote:
>
>> I am working with a case control dataset with gene clusters variables.  I have approx 100 observations, a handful of essential variables, but approx. 14,000 variables for each observation that represent gene clusters (absent/present, 0/1).  The gene variables are all located next to each other in the dataset (i.e., gene1-gene14000).
>>
>> I would like to drop variables for gene clusters that are not present among my cases.  Obviously, specifying each gene cluster variable would be impractical.
>>
>> Is there any way to do this in Stata?  I'm stumped.

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