Version 16.1
I have 4 variables - firm_id, type_product, type_airframe, and Application of each product.
Each firm can have 1 product or multiple products (firm 1 has 9 types of products). Each product can have 3 different types of the airframe, and can have multiple applications.
* I have 2 questions -
1. how can i create a variable "count" that shows different types of airframes sold by each firm. I have shown a count variable in the sample data
2. How can I create a variable "total_apps" that counts different applications (no repetition) across all the products per firm? OR
How many unique applications are there per firm_id?
I tried to split the variable Application using code
-
split Application, p(

Got stuck after that. Please see the example using dataex below.
Thanks
***
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(firm_id type_product) long type_airframe float count str428 Application 1 1 1 2 "Disaster Response; Environmental Research or Monitoring; Firefighting; Hobby; Imaging; Inspection; Mining; Precision Agriculture; Research; Search & Rescue; Survey, Mapping" 1 2 2 2 "Education; Environmental Research or Monitoring; Hobby; Imaging; Inspection; Research" 1 3 2 2 "Disaster Response; Environmental Research or Monitoring; Hobby; Imaging; Inspection; Precision Agriculture; Research; Search & Rescue; Survey, Mapping" 1 4 2 2 "Environmental Research or Monitoring; Hobby; Imaging; Inspection; Precision Agriculture; Survey, Mapping" 1 5 2 2 "Cable Services; Disaster Response; Environmental Research or Monitoring; Hobby; Imaging; Inspection; Mining; Precision Agriculture; Search & Rescue; Survey, Mapping" 1 6 2 2 "Disaster Response; Environmental Research or Monitoring; Hobby; Imaging; Inspection; Precision Agriculture; Research; Survey, Mapping" 1 7 2 2 "Cable Services; Disaster Response; Environmental Research or Monitoring; Hobby; Imaging; Inspection; Intelligence, Surveillance, Reconnaissance; Patrol, Security; Precision Agriculture; Search & Rescue; Survey, Mapping" 1 8 2 2 "Cable Services; Disaster Response; Environmental Research or Monitoring; Imaging; Inspection; Mining; Precision Agriculture; Survey, Mapping" 1 9 2 2 "Cable Services; Imaging; Inspection; Mining; Pipeline Services; Precision Agriculture; Survey, Mapping" 2 1 1 1 "Disaster Response; Environmental Research or Monitoring; Imaging; Intelligence, Surveillance, Reconnaissance; Patrol, Security; Prototype; Research; Survey, Mapping" 3 1 2 1 "Cable Services; Imaging; Inspection; Intelligence, Surveillance, Reconnaissance; Patrol, Security; Pipeline Services; Precision Agriculture; Search & Rescue" 4 1 1 3 "Imaging; Intelligence, Surveillance, Reconnaissance; Patrol, Security; Target Acquisition" 4 2 3 3 "Communications; Disaster Response; Imaging; Intelligence, Surveillance, Reconnaissance; Patrol, Security; Search & Rescue; Survey, Mapping" 4 3 2 3 "Attack, Weapons Delivery; Communications; Imaging; Inspection; Intelligence, Surveillance, Reconnaissance; Logistics; Patrol, Security; Target Acquisition" 4 4 2 3 "Disaster Response; Firefighting; Imaging; Inspection; Intelligence, Surveillance, Reconnaissance; Observation; Patrol, Security; Search & Rescue; Target Acquisition" 4 5 3 3 "Communications; Disaster Response; Imaging; Intelligence, Surveillance, Reconnaissance; Patrol, Security; Search & Rescue; Survey, Mapping; Target Acquisition" 4 6 1 3 "Attack, Weapons Delivery; Target Acquisition" end label values type_airframe airframe1
0 Response to Problem with Counting observations across firm identifier
Post a Comment