Announcement

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

  • Vlookup Function For A Large Dataset

    Hi all,

    I am working on a large dataset A (10,000 observations). I want to match the Gender (variable Sex) and the Occupation code (variable SOC2010B) from dataset A with a small dataset B (39 observations), which contains Gender, Occupation Code and Estimated Weekly Earnings. My ideal outcome is that Dataset A will have one more variable of Estimated Weekly Earnings, which is retrieved from dataset B. It would be very easy if I can do Vlookup on Excel.

    Below is the sample dataex of Dataset A. Dataset B is similar, with an addition of Estimated Weekly Earnings.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte(Sex SOC2010B)
    2 61
    1 82
    2 22
    1 92
    1 82
    1 35
    1 53
    1 52
    2 71
    1 11
    1 53
    Could anyone share me the code for this kind of Vlookup function? I would very much appreciate!!

    Thank you so much!!

  • #2
    Code:
    merge m:1 Sex SOC2010B using Dataset_B, keep(match master)

    Comment


    • #3
      Code:
      h merge
      this is just a guess since I have no idea what a VLOOKUP function in Excel is or does (and I don't have excel); if you had also provided example data from the other file, then exact code could have been given but my guess is that if you have file A in memory you want
      Code:
      merge m:1 Sex SOC2010B using B
      added in edit: crossed with #2 whose guess is slightly more specific

      Comment


      • #4
        Originally posted by Clyde Schechter View Post
        Code:
        merge m:1 Sex SOC2010B using Dataset_B, keep(match master)
        Thank you so much!! It works!!

        Comment

        Working...
        X