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: subsetting a dataset


From   William Buchanan <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: subsetting a dataset
Date   Sat, 5 Jan 2013 21:50:19 -0800

Wouldn't it be easier to reshape one of your datasets and then -merge- it with the other? The example that you provided below is vague and I would assume a poor representation of what your ultimate goal is.  In the example you have below it isn't clear why you need the first dataset in the first place, since it just seems to be away that you are grouping variable names. In that case you could use the gene name with a wildcard in place of the number to do the same thing.

HTH,
Billy

Sent from my iPhone

On Jan 5, 2013, at 20:52, Samir Kelada <[email protected]> wrote:

> The gist of my question is whether one can select variables (columns) from one dataset based on observations (rows) from another.
> 
> Dataset 1
> Module    Gene_name
> 1    abca1
> 1    abca2
> 2    slc3
> 2    slc4
> 2    slc6
> 3    htr1
> 3    htr2
> 4    scgb1
> 4    scgb12
> 4    scgb14
> 4    scgb45
> …
> 
> Dataset 2:
> Subject abca1 abca2 slc3 slc4 … gene_n 
> 100    2    4    6    8 …
> 101    2    8    6    6 …
> 102    3    6    7    8 …
> …
> 
> Code I would like to use would look something like this:
> clear
> use dataset1
> levelsof (module), local levels
> foreach rep of local(levels) {
>    clear
>    use dataset2
>    - keep subject AND all columns that match row labels corresponding to value of local level; e.g. if `rep’==1, keep abca1, abca2, and subject
>    [do a calculation and save output to a file]
>    }
> 
> 
> Samir Kelada
> *
> *   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/

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