Announcement

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

  • Creating dummy variables

    Dear Statalists,

    This is my first post.

    I have a challenge in generating dummy variables using a variable list which contains non-numeric values (so labels of country codes). Specifically I have a long list of country codes (i.e. AT, BE ext) and I want to create 4 dummies corresponding to three blocks of countries i.e: EU_North (if AT, BE DE) EU_South (if PT, SP) ext and I type the following two commands and get the following message:

    generate EU_total = 0

    1. replace EU_total = 1 if countrycode == AT | BE | FR | DE | GB | IE | ES | IT | NL | LU | PT | SE | FI
    AT not found
    r(111);


    2. replace EU_total = 1 if countrycode == AT | countrycode == BE | countrycode == FR | countrycode == DE | countryc
    > ode == GB | countrycode == IE | countrycode == ES | countrycode == IT | countrycode == NL | countrycode ==
    > LU | countrycode == PT | countrycode == SE | countrycode == FI
    AT not found
    r(111);




    I have converted countrycode from string to non numeric

    describe countrycode

    storage display value
    variable name type format label variable label
    ------------------------------------------------------------------------------------------------------------
    countrycode long %8.0g countrycode
    ΚΩΔ_ΧΩΡ


    Does this mean that I cannot use labels in the dummy command?

    I then want to collapse (sum) my values based on the 4 dummies to get aggregate figures for each dummy/country block.

    Thank you for any ideas or insight you might have!
Working...
X