Dear Statalisters,
My request is simple, but I give a lot of explanation to make the data clear. Thanks for your patience !
Below I present a few observation of a panel data set. The data is organized by
the three firms have a common trait – their primaryid is the same 3100, primaryid denotes the segment a firm has the largest sales. E.g. firm 1000 has 2 segments 3100, 3200, the largest sales is in 3100. (think about a gas station, selling snacks, and gas, as two distinct segments)
My request: (you shall see the data I want below)
data want
You may notice I have 3 firmid, each firmid corresponds to 3 segmentid. Only segments with non-zero sales are real segment id, that is, the firm does operate in the segment. I processed the data to include all possible segments for all firms, for future analysis.
Thank you,
Rochelle
My request is simple, but I give a lot of explanation to make the data clear. Thanks for your patience !
Below I present a few observation of a panel data set. The data is organized by
- firm and segment
Code:
clear input int(firmid segmentid) str4 primaryid byte segsale 1000 3100 "3100" 40 1000 3200 "." 10 1000 3300 "." 0 2000 3100 "3100" 15 2000 3200 "." 0 2000 3300 "." 0 1200 3200 "." 0 1200 3300 "." 12 1200 3100 "3100" 49 end
the three firms have a common trait – their primaryid is the same 3100, primaryid denotes the segment a firm has the largest sales. E.g. firm 1000 has 2 segments 3100, 3200, the largest sales is in 3100. (think about a gas station, selling snacks, and gas, as two distinct segments)
My request: (you shall see the data I want below)
- I want to generate 2 new variables sid1 sid2 that takes values of all non-primaryid, in this case, 3200, 3300,
- Next, I want to merge these variables back to the main dataset. ( I know how to merge ,but not sure how to do 1 above)
data want
Code:
clear input int(firmid segmentid) str4 primaryid byte segsale int(sid1 sid2) 1000 3100 "3100" 40 . . 1000 3200 "." 10 3200 . 1000 3300 "." 0 . . 2000 3100 "3100" 15 . . 2000 3200 "." 0 . . 2000 3300 "." 0 . . 1200 3200 "." 0 . . 1200 3300 "." 12 . 3300 1200 3100 "3100" 49 . . end
Thank you,
Rochelle
Comment