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]
st: subsetting a dataset
From
Samir Kelada <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: subsetting a dataset
Date
Sat, 5 Jan 2013 23:52:57 -0500
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/