Hi,
Please consider the following example data:
I want find mode of pcd based on following conditions:
I have been iterating on this but haven't managed to combine the value of yearschool with each of the macros to solve this.
Would appreciate any help, thanks!
Please consider the following example data:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str3 id float year str3 pcd float(school flag1 yearschool) "111" 2011 "AAC" 123 1 2 "111" 2012 "AAA" 124 1 4 "111" 2013 "AAA" 124 1 5 "112" 2010 "AAA" 123 1 1 "112" 2011 "AAA" 123 1 2 "112" 2012 "AAB" 123 1 3 "113" 2014 "AAB" 126 1 7 "113" 2015 "AAB" 127 1 8 "113" 2016 "AAC" 128 1 10 "113" 2017 "AAA" 128 1 12 "115" 2011 "AAC" 123 0 2 "115" 2012 "AAB" 124 0 4 "115" 2013 "AAC" 128 0 6 "116" 2016 "AAC" 127 0 9 "116" 2017 "AAA" 127 0 11 "117" 2011 "AAB" 123 0 2 "117" 2015 "AAB" 127 0 8 end local good if flag==0 local bad if flag==1
for each id corresponding to a value of yearschool in "bad", I want to find observations in "good" having same value of yearschool, and then take the mode of the corresponding pcd.
So for each id in "bad", we will have a modal pcd based on the ids in "good"
So for each id in "bad", we will have a modal pcd based on the ids in "good"
Would appreciate any help, thanks!
Comment