Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Cox <njcoxstata@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: combining two variables of different type |
Date | Thu, 20 Jan 2011 17:33:28 +0000 |
You haven't explained what types your variables are. Perhaps you want concatenation, in which case -egen, concat()- is convenient. Otherwise, gen combined = string(numeric_var) + strvar is a recipe for combining two variables as if they were both string. Nick On Thu, Jan 20, 2011 at 5:00 PM, Kristen Shorette <kshorett@uci.edu> wrote: > How can I combine two variables of different type. For example, I am using > a panel data set where countries are the units of analysis and I want a > variable CountryYear (AFG1985). I have the countries and years each as > variables but when I use "gen countryyear=country+year" I get the error > "type mismatch". > > Thanks, > Kristen > > > > * > * 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/ > * * 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/