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]

st: read values of tempvar instead of variable label


From   Erik van Ingen <ejvani@hotmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: read values of tempvar instead of variable label
Date   Fri, 4 May 2012 12:41:52 +0000

Dear all, Sorry to ask such a newbie question, but I can't find the answer elsewhere. Can anyone please tell me how to get the code below to work? I am trying to use tempvar in order to use the value of a variable to address another variable. I get the error message "othervar__000000 not found": Stata replaces the local with the variable label of "tmpnr" instead of its value (for each case in the data). Any help would be much appreciated. Best,Erik van Ingen.

gen newvar=.tempvar tmpnrgen `tmpnr'= var1    // var1 is in my data and ranges from 1 to 12replace newvar=1 if othervar`tmpnr'==1    // othervar1 to othervar12 are also in my data (dummy vars)



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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index