Hello,
I have a variable, primarycarephysicianstandard, and several variables like it, that have several observations, which I want to pull apart into separate variables, while still keeping some part of the variables as it currently exists. Specificially, the variable tabulates as:
$10
$10 copay before deductible
$10 copay before deductible and 15% coinsurance after deductible
$15 copay after deductible
$30 copay and 20% coinsurance after deductible
30%
No charge after deductible
*Note: the variable continues in this fashion with different numbers, and there are several variables like this one*
What I want to do is split the variable up into three variables so that it looks something like the following:
Each observation will have one of these rows
For example, if observation 1 has a $115 dollar copay before deductible and 15% coinsurance after deductible and observation 2 has a $20 copay after deductible, the observation list for this variable would like like the following:
I have tried using 'split' and concatenating the pieces I need back together, which does not work because the text does not line up using spaces, and I cannot figure out how to add characters to delimit the text the way I want. I have also tried 'regexm' and 'generate' and 'replace' for the new variables.
Any help on this would be so very much appreciated!
I have a variable, primarycarephysicianstandard, and several variables like it, that have several observations, which I want to pull apart into separate variables, while still keeping some part of the variables as it currently exists. Specificially, the variable tabulates as:
$10
$10 copay before deductible
$10 copay before deductible and 15% coinsurance after deductible
$15 copay after deductible
$30 copay and 20% coinsurance after deductible
30%
No charge after deductible
*Note: the variable continues in this fashion with different numbers, and there are several variables like this one*
What I want to do is split the variable up into three variables so that it looks something like the following:
Each observation will have one of these rows
Primarycarephysicianstandard (original variable) | Primarycarephysician Dollar (new variable) | Primarycarephsyciain Percent (new variable) |
Dollar amount | 10 | |
Dollar copay before deductible | 10 | |
Dollar copay before deductible and percent coinsurance after deductible | 10 | 15 |
Dollar copay after deductible | 15 | |
Dollar copay and percent coinsurance after deductible | 30 | 30 |
Percent | 30 | |
No charge after deductible | ||
No charge |
Obs | Primarycarephysician | Primarycarephysician dollar | Primarycarephysician percent |
1 | Dollar copay before deductible and percent coinsurance after deductible | 115 | 15 |
2 | Dollar copay after deductible | 20 |
I have tried using 'split' and concatenating the pieces I need back together, which does not work because the text does not line up using spaces, and I cannot figure out how to add characters to delimit the text the way I want. I have also tried 'regexm' and 'generate' and 'replace' for the new variables.
Any help on this would be so very much appreciated!
Comment