Hi everyone,
I have to do this for 69 car brands:
Is there a way to come back to the "original version", with the changes made in my -model- variable?
Here a small dataex from my -collapse-:
Thank you in advance for your help!
Michael
- Is there a way to use -collapse- to aggregate data, do some data modifications and then return to the full data with changes?
I have to do this for 69 car brands:
Code:
keep if description == "PEUGEOT" replace model = itrim(trim(model)) gen num = 1 collapse (sum) num, by(description model COD_PROPULSION cilindrada potenciafiscal weight_max) tab model [aw=num] strgroup model, generate(similar_model1) threshold(0.15) first normalize(shorter) force replace model = "1007" if inrange(similar_model1, 8, 9) replace model = "106" if inrange(similar_model1, 10, 13) replace model = "107" if inrange(similar_model1, 14, 15) replace model = "108" if inrange(similar_model1, 16, 70) /// | (similar_model1 == 1 & ustrpos(model, "108")>0) ...
Here a small dataex from my -collapse-:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str23 description str31 model str1 COD_PROPULSION long cilindrada double potenciafiscal long weight_max double num long similar_model1 "PEUGEOT" "108" "0" 1199 8.73 1240 1 26 "PEUGEOT" "108" "0" 1199 8.73 1240 1 27 "PEUGEOT" "108" "0" 1199 8.73 1240 1 1 "PEUGEOT" "108" "0" 1199 8.73 1240 25 1 "PEUGEOT" "108" "0" 998 7.82 1240 1 1 "PEUGEOT" "108" "0" 998 7.82 1240 1 24 end
Thank you in advance for your help!
Michael
Comment