Announcement

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

  • storing information from merging

    Hi Stata users,

    I am working with merging datasets in a loop (meaning at least hundreds of merging). However, I need to save the value of unmatched observations as a new variable. Is it possible to do it in Stata?

    Click image for larger version

Name:	snipping.PNG
Views:	1
Size:	10.4 KB
ID:	1737772


    For example, after the merging I want to create a variable and store 983, 770 and so on as its values.

    Any help would be highly appreciated.

    Best,
    Zariab Hossain
    Uppsala University

  • #2
    Well, unless you have specified the -nogenerate- option in your -merge- command (in which case, you should remove it) -merge- automatically creates this for you. Your data set has a new variable called _merge which takes on the value 1 for master only, 2 for using only, and 3 for matched. If you need to access the total number in each group you can do -tab _merge- to see it in the Results window. Or if you need another variable that gives those counts:
    Code:
    by _merge, sort: gen `c(obs_t)' wanted = _N

    Comment


    • #3
      Dear Clyde

      Thanks a lot for your suggestion. It worked.

      Comment

      Working...
      X