I have a crossection of electric vehicle (EV). charging stations, and can identify the network a station belongs to and the county it lies. Variable L2 is just an Indicator for station having L2 technology, and variabe L2_chargers is the total number of L2 EV Chargers at the station.
I want to create two variables measuring intensity of competition for each station in the following manner -
1. comp_stations: The number of L2 stations in a county that do not belong to the same station level network . For example, in county "01003", this variable takes on a value of 5 for station id "112707" and a value of 3 for station id "46687".
2. comp_chargers: The number of L2 chargers in a county that do not belong to the same station level network. For example, in county "01003", this variable takes on a value of 7 for or station id "112707" and a value of 7 for station id "46687".
I am not sure how to / whether I can use an if conditional on the evnetwork value corresponding to each observation -
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long id float L2 int L2_chargers str5 STCOUNTYF str19 evnetwork 112707 1 1 "01003" "Tesla Destination" 46687 1 2 "01003" "Non-Networked" 72205 1 1 "01003" "Non-Networked" 39850 1 1 "01003" "Non-Networked" 72206 1 1 "01003" "Non-Networked" 112721 1 1 "01003" "Tesla Destination" 118018 1 2 "01003" "ChargePoint Network" 122353 1 2 "01003" "Tesla Destination" 112719 1 1 "01003" "Tesla Destination" 112697 1 5 "01073" "Tesla Destination" 105151 1 1 "01073" "ChargePoint Network" 103823 1 2 "01073" "ChargePoint Network" 46677 1 1 "01073" "Non-Networked" 39849 1 1 "01073" "Non-Networked" 112696 1 2 "01073" "Tesla Destination" 112701 1 2 "01073" "Tesla Destination" 81218 1 2 "01073" "ChargePoint Network" 112710 1 2 "01073" "Tesla Destination" 81317 1 4 "01073" "ChargePoint Network" 81217 1 2 "01073" "ChargePoint Network" 101974 0 0 "01073" "Tesla" 46673 1 1 "01073" "Non-Networked" 80384 1 2 "01073" "Non-Networked" 46675 1 2 "01073" "Non-Networked" 112699 1 4 "01073" "Tesla Destination" 89926 1 2 "01073" "Non-Networked" 50422 1 1 "01073" "ChargePoint Network" 147054 1 1 "01073" "ChargePoint Network" 112702 1 3 "01073" "Tesla Destination" 62730 1 2 "01073" "ChargePoint Network" 81851 1 2 "01089" "ChargePoint Network" 123472 1 2 "01089" "ChargePoint Network" 62977 0 0 "01089" "Non-Networked" 105012 1 1 "01089" "ChargePoint Network" 82760 1 2 "01089" "ChargePoint Network" 61846 1 2 "01089" "ChargePoint Network" 143605 1 2 "01097" "ChargePoint Network" 143606 1 2 "01097" "ChargePoint Network" 144225 1 2 "01097" "ChargePoint Network" 144224 1 2 "01097" "ChargePoint Network" 143526 1 2 "01097" "ChargePoint Network" 144145 1 2 "01097" "ChargePoint Network" 112713 1 2 "01097" "Tesla Destination" 143520 1 2 "01097" "ChargePoint Network" 71516 1 1 "01097" "Non-Networked" 143607 1 2 "01097" "ChargePoint Network" 143523 1 2 "01097" "ChargePoint Network" 143521 1 2 "01097" "ChargePoint Network" 143524 1 2 "01097" "ChargePoint Network" 143529 1 2 "01097" "ChargePoint Network" 143528 1 2 "01097" "ChargePoint Network" 112712 1 1 "01097" "Tesla Destination" 122351 1 2 "01097" "Tesla Destination" 101976 0 0 "01097" "Tesla" 102661 1 2 "01097" "ChargePoint Network" 112715 1 4 "01101" "Tesla Destination" 85589 1 1 "02110" "Non-Networked" 72524 1 2 "02110" "Non-Networked" 117442 1 2 "02110" "Non-Networked" 117440 0 0 "02110" "Non-Networked" 117439 1 2 "02110" "Non-Networked" 122191 0 0 "02110" "Non-Networked" 81601 1 2 "02110" "Non-Networked" 117441 1 1 "02110" "Non-Networked" 117437 1 2 "02110" "Non-Networked" 101996 0 0 "04003" "Tesla" 123483 0 0 "04003" "Electrify America" 118886 0 0 "04005" "ChargePoint Network" 136271 1 2 "04005" "Tesla Destination" 112761 1 2 "04005" "Tesla Destination" 112825 1 2 "04005" "Tesla Destination" 98612 1 4 "04005" "ChargePoint Network" 103565 1 2 "04005" "Non-Networked" 101987 0 0 "04005" "Tesla" 127934 0 0 "04005" "Electrify America" 148501 1 2 "04005" "SemaCharge Network" 112764 1 2 "04005" "Tesla Destination" 103563 1 2 "04005" "Non-Networked" 76908 1 2 "04005" "Non-Networked" 112765 1 2 "04005" "Tesla Destination" 73714 1 1 "04005" "Non-Networked" 122358 1 2 "04005" "Tesla Destination" 112767 1 4 "04005" "Tesla Destination" 112769 1 2 "04005" "Tesla Destination" 112766 1 1 "04005" "Tesla Destination" 122357 1 3 "04005" "Tesla Destination" 101982 0 0 "04005" "Tesla" 123629 1 1 "04013" "ChargePoint Network" 95824 1 3 "04013" "Blink Network" 112781 1 6 "04013" "Tesla Destination" 118210 1 2 "04013" "ChargePoint Network" 147021 1 2 "04013" "ChargePoint Network" 101991 0 0 "04013" "Tesla" 144097 1 1 "04013" "Blink Network" 148754 1 1 "04013" "SemaCharge Network" 80835 1 6 "04013" "ChargePoint Network" 95385 1 1 "04013" "Blink Network" 82599 1 2 "04013" "ChargePoint Network" 146603 1 2 "04013" "ChargePoint Network" 95228 1 2 "04013" "Blink Network" end egen comp_stations=total(L2) if evnetwork!="evnetwork[_n]", by (STCOUNTYF) //not exactly what I need gets generated egen comp_chargers=total(L2_chargers) if evnetwork!="evnetwork[_n]", by (STCOUNTYF)
0 Response to Calculating total or sum without own observation class
Post a Comment