Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: combining different storage types

From   Nick Cox <>
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.


On Sat, Oct 8, 2011 at 4:45 PM, Edward James <> 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 <>:
>> 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 <> 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 <>:
>>>> 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 <> 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:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index