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 different storage types |
Date | Sat, 8 Oct 2011 16:50:38 +0100 |
OK. So you haven't after all done this (and I misunderstood "I manage to combine..."). That is indeed illegal. egen ctryear = group(country year), valuelabel egen ctryear = concat(country year) gen ctryear = country + string(year) are three ways of doing what you want. The first is the best for most purposes. Nick On Sat, Oct 8, 2011 at 4:45 PM, Edward James <ej111005@gmail.com> wrote: > When I type command like this way, "gen ctryear=country + year", the > error message comes up: "type mismatch" > Do I have to use another command? > > > 2011/10/9 Nick Cox <njcoxstata@gmail.com>: >> Sorry, but I did understand that, and my comment is the same. You >> don't explain in what sense you have a problem. I see no problem here. >> >> You said, or at least I inferred, that you have produced such a >> variable, but perhaps you did not mean to say that. >> >> Nick >> >> On Sat, Oct 8, 2011 at 4:34 PM, Edward James <ej111005@gmail.com> wrote: >>> Dear Nick. >>> My intention is that I want to combine two variables which has >>> different storage types; one is "str" and the other is "int." >>> >>> 2011/10/9 Nick Cox <njcoxstata@gmail.com>: >>>> It is not clear what you think is a problem. Something like "Spain95" >>>> could be the value of a string variable or the value label of a >>>> numeric variable, which seems as much flexibility as you might want. >>>> >>>> Apart from -graph combine-, not relevant here, the -combine- command >>>> appears to be a specialist user-written command for meta-analysts on >>>> SSC. Again what it has to do with your question isn't clear. >>>> >>>> (Very common words such as -combine- are likely to be grabbed by >>>> StataCorp for their own commands.) >>>> >>>> Nick >>>> >>>> On Sat, Oct 8, 2011 at 4:19 PM, Edward James <ej111005@gmail.com> wrote: >>>> >>>>> I want to make a variable such as "Spain95" or "Germany05." So I >>>>> manage to combine two variables, "country" and "year," although the >>>>> storage type is different. >>>>> Is it possible to make a variable with -combine- command? or do you >>>>> have any idea concerning this problem? >>>> * * 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/