I have a string variable that tells me what insurances are accepted by individual doctors.
For example, for the first doctor in the dataset we have that:
Code:
Insurance=="||Aetna|||BlueCrossandBlueShield|||CHIP|Children'sProgram|||Cigna|||Medicaid|||Medicare|||UnitedHealthCare|||OutofNetwork||"
Each doctor accepts different brand of insurances and a different quantity of insurances.
I would like to create a dummy variable for every insurance.
These goals can be reached passing through two different tasks (at least):
1) presume that the first step should be that of creating the list of all of the possible insurances that are accepted by the doctors in my data set.
Is there a way other than creating a list by hand?
2) when I have created this list (or vector) of all of the possible insurances accepted by doctors in the data set, I can create a dummy for each insurance company.
For example:
Code:
gen Aetna = . replace Aetna = 0 if Insurance!="NA" replace Aetna = 1 if regexm(Insurance, "(Aetna)")
0 Response to Generate dummies from list of strings
Post a Comment