Hi all,
I am working on this dataset, in which I would like to test whether the cumulative sum of the variable 'votes_margin' for order_m = 2 and 3 is greater than order_m of 1.
1. Therefore, for each id indicated by the variable 'ac', I would like to create a cumulative sum of the variable 'votes_margin' but only for the values of order_m of 2 and 3.
2. Then, create a dummy indicating whether this cumulative sum of order_m values 2 and 3 is greater than or lesser than order_m of 1, for each id.
Any suggestions would be helpful.
I have provided the example dataset by using dataex, below for your kind verification.
Thanks.
I am working on this dataset, in which I would like to test whether the cumulative sum of the variable 'votes_margin' for order_m = 2 and 3 is greater than order_m of 1.
1. Therefore, for each id indicated by the variable 'ac', I would like to create a cumulative sum of the variable 'votes_margin' but only for the values of order_m of 2 and 3.
2. Then, create a dummy indicating whether this cumulative sum of order_m values 2 and 3 is greater than or lesser than order_m of 1, for each id.
Any suggestions would be helpful.
I have provided the example dataset by using dataex, below for your kind verification.
Thanks.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str14 state_m str30 constituency float year_m str55 candidate_m double votes_margin long ac float order_m str24 const_m "Andhra Pradesh" " ACHAMPET (SC)" 2004 " DR.VAMSHI KRISHNA" .538547933101654 2 1 "Achampet" "Andhra Pradesh" " ACHAMPET (SC)" 2004 " P.RAMULU" .36918625235557556 2 2 "Achampet" "Andhra Pradesh" " ACHAMPET (SC)" 2004 " YAMGONDI VENKATAIAH" .046903301030397415 2 3 "Achampet" "Andhra Pradesh" " ACHANTA (SC)" 2004 " PEETHALA SUJATHA" .4994221329689026 3 1 "Achanta" "Andhra Pradesh" " ACHANTA (SC)" 2004 " ANAND PRAKASH CHELLEM" .43905702233314514 3 2 "Achanta" "Andhra Pradesh" " ACHANTA (SC)" 2004 " JOSHIP MERIPE" .043371714651584625 3 3 "Achanta" "Andhra Pradesh" " ALAIR (SC)" 2004 " DR. KUDUDULA NAGESH" .5575404167175293 12 1 "Alair" "Andhra Pradesh" " ALAIR (SC)" 2004 " MOTHUKUPALLY NARSIMHULU" .3478609621524811 12 2 "Alair" "Andhra Pradesh" " ALAIR (SC)" 2004 " DR. ETIKALA PURUSHOTHAM" .02296549640595913 12 3 "Alair" "Andhra Pradesh" " ALLAVARAM (SC)" 2004 " GOLLAPALLI SURYARAO" .5028068423271179 14 1 "Allavaram" "Andhra Pradesh" " ALLAVARAM (SC)" 2004 " PANDU SWARUPA RANI" .4317871034145355 14 2 "Allavaram" "Andhra Pradesh" " ALLAVARAM (SC)" 2004 " ETHAKOTA THUKKESWARA RAO" .04949498176574707 14 3 "Allavaram" end label values ac ac label def ac 2 " ACHAMPET (SC)", modify label def ac 3 " ACHANTA (SC)", modify label def ac 12 " ALAIR (SC)", modify label def ac 14 " ALLAVARAM (SC)", modify
Comment