I am Working national police-reported accident dataset, with more than 30 variables and around 2000 rows. I am using a government database where I can only extract aggregated data and not single cases into a CSV or an excel sheet.
How can I group the following data (an example of the data, not the actual data) :
PS - The numbers are coded values that represent a certain categories, hence I am only interested in the count in each group.
""
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(Area highway accidenttype) 1 5 13 2 3 15 2 5 13 2 3 16 2 5 13 1 3 19 1 3 19 end
Into - the output should have a hierarchical subgrouping as follows:
Area Highway accidnettype Count
1 5. 19 1
3 19 2
2. 3. 16. 1
3 15. 1
5. 15. 2
Interpretation. There are two accidents of type 19 , in a highway 3 and in area 1.
Hope this makes sense!
Kind regards,
Fridah
0 Response to Problem grouping hierarchical data into subset of the data
Post a Comment