Announcement

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

  • test formatting



    I am using Stata version 18.0 on Windows 10.

    Code:
    clear
    set obs 10
    gen id = _n
    input str12 color_code
    rd
    blk
    bl
    yl
    vl
    cy
    gr
    wt
    pnk
    end
    gen color_name = ""
    local list1 "rd" "blk" "bl" "yl" "vl" "cy" "gr" "wt"
    local list2 "red" "black" "blue" "yellow" "violet" "cyan" "green" "white"
    local n : word count `list1'
    di "`n'"
    forvalues i = 1/`n' {
        local x : word `i' of `list1'
        local y : word `i' of `list2'
        di "`x' " 
        di " `y'" 
        replace color_name = "`y'" if color_code == "`x'"
        list color_code color_name in 1/10
    }
Working...
X