See Example Data Set:
So I'm trying to create a copy of the variable "Damage Repair Costs" that ignores everything that isn't just a calculable number; this includes the removal of the unnecessary decimals. (Note: there is an intentional space in the first row.) I don't want to change the original data set, just create a copy variable with all of the desired transformations.
I've tried:
But I'm having two issues.
1. Under the command line,
I get the following :
Additionally, I have an interesting caveat here. I want to be able to ignore spaces (e.g. $ 420), but not treating them exactly the same. Where there's a space in this first data point, I want to replace "Amount Too Small" with a "." -- but both have spaces.
2. Under the command line,
I get the following:
What am I doing wrong here? How can I get this data to be reduced to just whole numbers?
Please keep in mind that this question does not reflect exactly what data I am truly working with, but is a fairly accurate recreation of it for what it is that I am trying to learn to do.
HTML Code:
tab damage_repair_costs
| Damage Repair Costs | Freq. |
| $ 420 | 800 |
| $690.00 | 15 |
| $500.00 | 3 |
| $550 | 180 |
| $900 | 4 |
| $799.00 | 72 |
| 40 | 2 |
| 528.00 | 1 |
| 655 | 6 |
| 978.00 | 7 |
| Amount Too Small | 1 |
I've tried:
HTML Code:
gen damage_repair_costs_transform = damage_repair_costs
destring damage_repair_costs_transform, gen(damage_costs_final) ignore("$" "." ".00" ",")
replace damage_costs_final = . if damage_repair_costs == "Amount Too Small"
1. Under the command line,
HTML Code:
destring damage_repair_costs_transform, gen(damage_costs_final) ignore("$" "." ".00" ",")
HTML Code:
damage_repair_costs_transform: contains characters not specified in ignore(); no generate
2. Under the command line,
HTML Code:
replace damage_costs_final = . if damage_repair_costs == "Amount Too Small"
HTML Code:
type mismatch r(109);
Please keep in mind that this question does not reflect exactly what data I am truly working with, but is a fairly accurate recreation of it for what it is that I am trying to learn to do.

Comment