problems with nwdrop / nwkeep after merging with attributes

96 views
Skip to first unread message

Virginia Gianinazzi

unread,
Jan 20, 2016, 11:51:02 AM1/20/16
to nwcommands
Hi,
I have merged my n-nodes network with a file containing some attributes. Now I want to keep only the m nodes for which the merge was successful.

I use

nwkeep if _m==3, attributes(varlist)

and

nwsummarize network

tells me that the network has now m nodes as it should have.

However, in the data browser the rows for which the merge was unsuccessful are still there.
I would appreciate very much if someone could help me understand my mistake.

Virginia









Thomas Grund

unread,
Jan 20, 2016, 2:28:24 PM1/20/16
to Virginia Gianinazzi, nwcommands
Hi Virginia,

you actually need to specify the variables for which you want to drop the observations. In your example you use "attributes(varlist)", but varlist is a place-holder for an actual list of variables. 

For example, if your attributes are stored in the variables A1, A2, B, C, the command

. nwkeep if _m==3, attributes(A* B C)

would drop the observations of these variables for which _m != 3.

Check out 

. help varlist

to learn more about variable lists.

Hope this helps.

Best,
Thomas


--
You received this message because you are subscribed to the Google Groups "nwcommands" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nwcommands+...@googlegroups.com.
Visit this group at https://groups.google.com/group/nwcommands.
To view this discussion on the web visit https://groups.google.com/d/msgid/nwcommands/51b263b0-767d-4bc5-bf15-4802072218dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Virginia Gianinazzi

unread,
Jan 21, 2016, 2:02:07 AM1/21/16
to nwcommands, virginia....@gmail.com
Hi Thomas
thank you for your answer.

Actually I am doing what you are saying, I just wrote varlist to keep it short. Sorry if that was confusing!
I copy the code below to make clear what I mean.

Virginia



. merge 1:1 _nodelab using CCM_2013.dta

    Result                           # of obs.
    -----------------------------------------
    not matched                         1,425
        from master                        42  (_merge==1)
        from using                      1,383  (_merge==2)

    matched                             4,012  (_merge==3)
    -----------------------------------------


. nwkeep if _m==3, attributes(sic)
(5,437 missing values generated)
(5,437 missing values generated)
(1,383 missing values generated)
(4,012 real changes made)
(5,437 missing values generated)
(5,437 missing values generated)
(1,425 missing values generated)
(5,395 real changes made, 5,395 to missing)


. list if _nodeid<20

      +--------------------------------------------------------+
      |  sic            _merge   _nodelab   _nodevar   _nodeid |
      |--------------------------------------------------------|
   1. | 5080       matched (3)       1004       net1         1 |
   2. | 4512       matched (3)       1045       net2         2 |
   3. | 3564       matched (3)       1050       net3         3 |
   4. | 3670       matched (3)       1072       net4         4 |
   5. | 4911       matched (3)       1075       net5         5 |
      |--------------------------------------------------------|
   6. | 7359       matched (3)       1076       net6         6 |
   7. | 2834       matched (3)       1078       net7         7 |
   8. | 5160       matched (3)       1094       net8         8 |
   9. | 3420       matched (3)       1104       net9         9 |
  10. | 3663       matched (3)       1117      net10        10 |
      |--------------------------------------------------------|
  11. | 5172       matched (3)       1121      net11        11 |
  12. | 3674       matched (3)       1161      net12        12 |
  13. | 6324   master only (1)       1177      net14        13 |
  14. | 2810       matched (3)       1209      net15        14 |
  15. | 4513       matched (3)       1210      net16        15 |
      |--------------------------------------------------------|
  16. | 4512       matched (3)       1230      net17        16 |
  17. | 3841       matched (3)       1234      net18        17 |
  18. | 4400       matched (3)       1254      net19        18 |
  19. | 6798       matched (3)       1257      net20        19 |
      +--------------------------------------------------------+
Reply all
Reply to author
Forward
0 new messages