Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Seok-Woo Kwon <kwonsw@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | st: data transformation |
Date | Sun, 3 Mar 2013 20:41:04 -0500 |
Dear all: I do not know how to describe my problem in general terms. So let me use an example to describe it. (I am using Stata 12 for Windows.) I have about 10,000 observations and 1,000 variables on individuals, but 4 observations and 3 variables will be enough to show the problem. My data looks like this: id X Y Z ----------------------- 001 1 2 X 002 2 3 Y 003 3 5 2 004 4 6 Y ----------------------- I need data that looks like this: id X Y Z Z_transformed -------------------------------------------- 001 1 2 X 1 002 2 3 Y 3 003 3 5 2 2 004 4 6 Y 6 -------------------------------------------- That is, some values in the variable "Z" will be a variable name (like "X" or "Y"). I would like to transform that variable into a value of that variable for the observation. For example, the value of Z for id 001 is X. Instead of X, I would like to show the value of X for id oo1 (which is 1). Is there a way to program this in Stata? Thank you. Seok-Woo Kwon * * 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/