I have a sample data with vars: id; location in certain year; sample weight. See attached (test.xlsx). I would like to get another data set which tracks the number of movements between locations by all possible locationpairs by year. The wanted data set also attached as xlsx. Hope this is clear from the attachment.
Announcement
Collapse
No announcement yet.
X

Hello Marcos:
Thanks for your information. I am new to stata. Here is my try to post my sample data and expected results.
Code:* Example generated by dataex. To install: ssc install dataex clear input byte id str2 location2000 str1(location2001 location2002) double weight 1 "a" "a" "a" 1.11 2 "a" "b" "a" 1.12 3 "b" "b" "b" .99 4 "b" "a" "a" 1.01 5 "b" "b" "a" 1.13 end
Code:* Example generated by dataex. To install: ssc install dataex clear input int year str1(from to) double count byte E str102 notesnotneededforthedatat 2001 "a" "a" 1.11 . "1.11 = 1*1.11, (count*sample_weight) i.e. from obs 1, moved from a to a (in year 2001 from year 200), " 2001 "a" "b" 1.12 . "from obs2" 2001 "b" "b" 2.12 . "from obs3 and 5: 1*0.99 + 1*1.13" 2001 "b" "a" 1.01 . "from obs4" 2002 "a" "a" 2.12 . "from obs 1 and 4: 1*1.11 + 1*1.01" 2002 "a" "b" 0 . "no movement observed" 2002 "b" "b" .99 . "from obs 3" 2002 "b" "a" 2.25 . "from obs2 and 5: 1*1.12 + 1*1.13" end
Thanks,
Joe
Comment
Comment