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: Identifying complicated varlist for foreach loop
From
Kyle Peyton <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: Identifying complicated varlist for foreach loop
Date
Fri, 15 Jul 2011 01:45:47 +0000
Hi all,
I have a very large dataset with some variables that I suspect have matching observations. I want to test this expectation and eliminate superfluous variables.
Essentially, I have two groups. In group 1, all variables have a prefix of "v". So we might have Vpen, Vshirt, Vfrog, etc. Let's assume I have 100 variables in group 1, all of them having this prefix "v"
In group 2, I have approximately 250 variables. Of those 250 variables, 100 variables are the same as those in group 1, minus the prefix. The other 150 I am certain are different. So we would have pen, shirt and frog, etc. My expectation (hope) is that this is the case and then I will be able to simply drop the variables with the "v" prefix from my dataset.
Is there a way to identify the SUFFIX of everything with a v PREFIX and then define that as a list? Then I'm thinking I can create a loop along these lines:
Foreach x in varlist (this is the varlist of my 100 important variables, my non-prefixed pens and frogs, etc.)
Assert `x' = v`x' (assuming this RHS works !)
This could be the completely wrong logic, however.
Any help or suggestion will be greatly appreciated! Thank you!
Kyle
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/