Announcement

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

  • egen newvar = group(oldvar), label

    Hi.

    I want to assign values to string data. Therefore I tried to convert the string var into a numeric one containing data like
    Code:
    fre new_numeric_var
    1 "theatre one"
    2 "central theatre"
    3 "museum downtown"
    4 "whatever"
    ...
    So, each text entered by the intereviewer for a respondent should be assigned a number - identical chars the same number (observations with 100% identical string answers the same number).
    I tried this submitting
    Code:
    egen t1m19v09_1_e0 = group(t1m19v09_1), label
    Stata prompts "too few quotes",
    So, according to Nick's recommendations in the thread
    https://www.stata.com/statalist/arch.../msg00712.html
    I checked varlabel ("Musik: Sonstiges (offen)") and
    Code:
    update query
    - but "all files are up to date".

    What options are left to be checked?
    Thank you for reading (and some reply)
    Using Stata 16.1
    Extractions (-dataex-) of the data I'm working with is impossible, sorry!

  • #2
    We need a data example


    Code:
    dataex t1m19v09_1

    Comment


    • #3
      Just for the sake of hazarding a guess, I wonder whether you wish something like:

      Code:
      . input str50 mystring
      
                                                     mystring
        1. "theatre one"
        2. "central theatre"
        3. "museum downtown"
        4. "whatever"
        5. end
      -----------------------+
      . encode mystring, gen(mycat1)
      
      . tab mycat1
      
               mycat1 |      Freq.     Percent        Cum.
      ----------------+-----------------------------------
      central theatre |          1       25.00       25.00
      museum downtown |          1       25.00       50.00
          theatre one |          1       25.00       75.00
             whatever |          1       25.00      100.00
      ----------------+-----------------------------------
                Total |          4      100.00
      
      
      . numlabel, add
      
      . tab mycat1
      
                  mycat1 |      Freq.     Percent        Cum.
      -------------------+-----------------------------------
      1. central theatre |          1       25.00       25.00
      2. museum downtown |          1       25.00       50.00
          3. theatre one |          1       25.00       75.00
             4. whatever |          1       25.00      100.00
      -------------------+-----------------------------------
                   Total |          4      100.00
      
      . list
      
           +--------------------------------------+
           |        mystring               mycat1 |
           |--------------------------------------|
        1. |     theatre one       3. theatre one |
        2. | central theatre   1. central theatre |
        3. | museum downtown   2. museum downtown |
        4. |        whatever          4. whatever |
           +---------------
      Best regards,

      Marcos

      Comment

      Working...
      X