Announcement

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

  • error: flag ambiguous abbreviation

    I have copied and pasted this same code successfully many times to create different variables within the NIS dataset. Now all of a sudden I get this error message: "flag ambiguous abbreviation" and can't figure out why. All help appreciated!

    Here is the code: use "/Users/ellenkiley/Library/Mobile Documents/com~apple~CloudDocs/Documents/NIS_PROJECT/Student Projects/Lior/Lior_fullsample_16", clear

    foreach v of varlist I10_DX1 - I10_DX40 {
    icd10cm generate flag_`v' = `v', range (O24.011/O24.33 O24.81/O24.93 E08.00/E13.49 Z79.4)
    replace flag = flag_`v' if flag_`v' > flag & flag_`v' != .
    }

    egen max1=rowmax(flag_I10_DX*)
    tab max1, m

    egen total1=rowtotal(flag_I10_DX*)
    tab total1, m

    gen codes1 =I10_DX1 if flag_I10_DX1 == 1
    foreach v of varlist I10_DX1 - I10_DX40 {
    replace codes1 = `v"' if flag_`v' == 1
    }

    tab codes1, m

    rename codes1 codes_PEDM
    rename flag ICD_PEDM
    rename max1 max_PEDM
    rename total1 total_PEDM
    drop flag_I10_DX*

    tab codes_PEDM, m
    tab ICD_PEDM,m
    tab max_PEDM, m

    save "/Users/ellenkiley/Library/Mobile Documents/com~apple~CloudDocs/Documents/NIS_PROJECT/Student Projects/Lior/Lior_fullsample_17", replace


    Here is the output:

    use "/Users/ellenkiley/Library/Mobile Documents/com~apple~CloudDocs/Documents/NI
    > S_PROJECT/Student Projects/Lior/Lior_fullsample_16", clear

    .
    . foreach v of varlist I10_DX1 - I10_DX40 {
    2. icd10cm generate flag_`v' = `v', range (O24.011/O24.33 O24.81/O24.93
    > E08.00/E13.49 Z79.4)
    3. replace flag = flag_`v' if flag_`v' > flag & flag_`v' != .
    4. }
    (0 real changes made)
    flag ambiguous abbreviation
    r(111);

    end of do-file

  • #2
    This error means that you have no variable in your dataset called 'flag', but you have multiple variables that begin with 'flag'. Do you want to generate an empty or 0 'flag' variable beforehand? I am afraid I can't help more without your data (see instructions for this in FAQ 12.2).

    Comment


    • #3
      Thanks! I forgot the gen flag = 0
      resolved!

      Comment

      Working...
      X