Announcement

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

  • Weird behavior of*vlookup (SSC, user kcrow)

    In short, when a value of edu is missing, it reports:
    multiple observations with different edu within pid.
    Whilst if values of edu are indeed not unique within pid, no error message is reported, where I would expect one.

    This is version version 1.0.1 31oct2015, the most current version of vlookup, and on Stata 15.1.

    Edit:
    Tagging user Kevin Crow (StataCorp) here
    Apologies, not from SSC, source is:
    Code:
    net install vlookup, from(http://www.stata.com/users/kcrow/)

    Code:
    * This runs fine
    clear
    input pid mother_id edu
     3115572 19556 40
     27313 19556 10
     19556 . 20
     end
    vlookup mother_id, gen(mother_edu) key(pid) value(edu)
    
    * where "value(edu)" is missing, a difficult to understand error message is reported about the uniqueness of edu within pid
    * I would simply expect missing values to be assigned
    clear
    input pid mother_id edu
     3115572 19556 40
     27313 19556 10
     19556 . .
     end
    vlookup mother_id, gen(mother_edu) key(pid) value(edu)
    
    * where edu is not unique within pid, no error message is reported, vlookup simply assigns the last value of edu to mother_edu
    clear
    input pid mother_id edu
     3115572 19556 40
     27313 19556 10
     19556 . 20
     19556 . 10
     19556 . 8
     end
    vlookup mother_id, gen(mother_edu) key(pid) value(edu)
    Last edited by Jorrit Gosens; 31 Aug 2018, 07:43.

  • #2
    Jorrit Gosens not sure if you figured out a workaround. I encountered a similar bug recently and posted a separate question. William Lisowski very kindly offered a workaround for vlookup in reply to my question, which you (or others who find this later) may find useful: https://www.statalist.org/forums/for...ror-in-vlookup.

    Comment

    Working...
    X