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

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


From   "Tamer Farag" <tfarag@medicine.umaryland.edu>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: drop range of variables meeting condition in another variable
Date   Mon, 18 Mar 2013 21:26:13 -0400

Many thanks, Nick.  I downloaded and installed findname.  However,  I am actually trying to apply two conditions, but it seems findname only applies 1.  I need to do the following:
 
1.  All of the gene variables have a value of 0, and 
2.  case==1
 
Is there a way to do the above?  
 
Also, I was not able to get the second part to work.  When I type: 
 
drop 'r(gene*)', I get an r(101) error "factor variables and time-series operators not allowed".  
 
When I alternatively try:
 
drop 'r(gene1-gene14000)', I get an r(100) error "varlist or in range required"
 
What am I doing wrong? 
 
Many thanks again,
Tamer
 
>>> Nick Cox <njcoxstata@gmail.com> 3/18/2013 4:26 PM >>>
Last line should be

drop `todrop'

Nick

On Mon, Mar 18, 2013 at 8:02 PM, Nick Cox <njcoxstata@gmail.com> 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
> <tfarag@medicine.umaryland.edu> 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/ 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information.  Any unauthorized use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. 

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