Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stata concanecate across observations grey out

    Hi there,

    I'm trying to concanecate a string variable in stata across observations. However, after the operation, the result i got turns into grey.

    I wonder if anyone knows how to fix this problem.

    Thanks

  • #2
    What colour (color) is used (in the Data Editor?) will depend on settings, which can be tuned. The only question of importance is whether the concatenation worked as hoped.

    For example, check out whether you can follow (and repeat) this:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str5 var1 str14 var2
    "Stata" "is good"       
    "X"     "is not so good"
    end
    
    . egen both = concat(var1 var2), p(" ")
    
    . list
    
         +-------------------------------------------+
         |  var1             var2               both |
         |-------------------------------------------|
      1. | Stata          is good      Stata is good |
      2. |     X   is not so good   X is not so good |
         +-------------------------------------------+
    Another way to do it -- so long as the expression contains only string variables and string constants -- is



    Code:
    . gen BOTH = var1 + " " + var2
    
    . l
    
         +--------------------------------------------------------------+
         |  var1             var2               both               BOTH |
         |--------------------------------------------------------------|
      1. | Stata          is good      Stata is good      Stata is good |
      2. |     X   is not so good   X is not so good   X is not so good |
         +--------------------------------------------------------------+
    .
    If that doesn't answer the question. please follow FAQ Advice #12 and give a data example using dataex.

    Detail: The jargon words concatenate, concatenation (occasionally catenate, catenation) have root the Latin word catena for chain. More detail at https://www.stata-journal.com/articl...article=pr0071 (which will emerge from behind a pay well in a matter of weeks).

    Comment

    Working...
    X