Hello everyone.
Following is an example data:
In the example data if we look at state of "Alabama", we see that region takes the value 3 where deaths are non-missing. I would like to replace region with all other values of region where the variable death is missing. Example of desired output:
Over here the example has sequenced numbers for region however, what if the sequence did not exist, how will the above problem be solved?
Following is an example data:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str14 state int region long pop65p float medage long death "Alabama" 3 440015 29.3 . "Alabama" 3 440015 29.3 . "Alabama" 3 440015 29.3 . "Alabama" 3 440015 29.3 35305 "Alaska" 4 11547 26.1 . "Alaska" 4 11547 26.1 . "Alaska" 4 11547 26.1 . "Alaska" 4 11547 26.1 1604 "Arizona" 4 307362 29.2 . "Arizona" 4 307362 29.2 . "Arizona" 4 307362 29.2 . "Arizona" 4 307362 29.2 21226 "Arkansas" 3 312477 30.6 . "Arkansas" 3 312477 30.6 . "Arkansas" 3 312477 30.6 . "Arkansas" 3 312477 30.6 22676 "California" 4 2414250 29.9 . "California" 4 2414250 29.9 . "California" 4 2414250 29.9 . "California" 4 2414250 29.9 186428 "Colorado" 4 247325 28.6 . "Colorado" 4 247325 28.6 . "Colorado" 4 247325 28.6 . "Colorado" 4 247325 28.6 18925 "Connecticut" 1 364864 32 . "Connecticut" 1 364864 32 . "Connecticut" 1 364864 32 . "Connecticut" 1 364864 32 26005 "Delaware" 3 59179 29.8 . "Delaware" 3 59179 29.8 . "Delaware" 3 59179 29.8 . "Delaware" 3 59179 29.8 5123 "Florida" 3 1687573 34.7 . "Florida" 3 1687573 34.7 . "Florida" 3 1687573 34.7 . "Florida" 3 1687573 34.7 104190 "Georgia" 3 516731 28.7 . "Georgia" 3 516731 28.7 . "Georgia" 3 516731 28.7 . "Georgia" 3 516731 28.7 44230 "Hawaii" 4 76150 28.4 . "Hawaii" 4 76150 28.4 . "Hawaii" 4 76150 28.4 . "Hawaii" 4 76150 28.4 4849 "Idaho" 4 93680 27.6 . "Idaho" 4 93680 27.6 . "Idaho" 4 93680 27.6 . "Idaho" 4 93680 27.6 6753 end label values region cenreg label def cenreg 1 "NE", modify label def cenreg 2 "N Cntrl", modify label def cenreg 3 "South", modify label def cenreg 4 "West", modify
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str14 state int region long pop65p float medage long death "Alabama" 1 440015 29.3 . "Alabama" 2 440015 29.3 . "Alabama" 4 440015 29.3 . "Alabama" 3 440015 29.3 35305 end
Comment