Hello,
I have data where some of the values are in dollars or percents and they are string variables in Stata (see price, sold, and ifallsold below). I would like to replace them with numeric variables so I can perform mathematical functions on them. Could someone please let me know the easiest/fastest way to do this?
Many thanks,
Alyssa
I have data where some of the values are in dollars or percents and they are string variables in Stata (see price, sold, and ifallsold below). I would like to replace them with numeric variables so I can perform mathematical functions on them. Could someone please let me know the easiest/fastest way to do this?
Many thanks,
Alyssa
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str15 crop str6 price str15 unitsize int(totalbrought totalsold) byte(balance notes) str7 sold float total str8 ifallsold float Month str8 Day "AAAAAA (TOTALS)" "" "" . . . . "" 2309.5 "2,742.50" 9 "Saturday" "APPLES" "$4.00" "bag" . . 0 . "." 0 "$0.00" 9 "Saturday" "SPROUTS" "$5.00" "bag" . . 0 . "." 0 "$0.00" 9 "Saturday" "ARUGULA" "$5.00" "bag" 54 25 29 . "46%" 125 "$270.00" 9 "Saturday" "ASPARAGUS" "$4.00" "bu" . . 0 . "." 0 "$0.00" 9 "Saturday" "BASIL" "$2.00" "bu/geniv" . . 0 . "." 0 "$0.00" 9 "Saturday" "BASIL" "$2.00" "bu/thai" . . 0 . "." 0 "$0.00" 9 "Saturday" "BASIL" "$2.00" "bu/lemon" . . 0 . "." 0 "$0.00" 9 "Saturday" "BASIL" "$2.00" "bu/blk opal" . . 0 . "." 0 "$0.00" 9 "Saturday" "BEANS" "$3.00" "qt/pole" . . 0 . "." 0 "$0.00" 9 "Saturday" "BEANS" "$3.00" "qt/string" . . 0 . "." 0 "$0.00" 9 "Saturday" "BEANS" "$3.00" "qt/wax" . . 0 . "." 0 "$0.00" 9 "Saturday" "BEANS" "$3.00" "qt/yellow" . . 0 . "." 0 "$0.00" 9 "Saturday" "BEANS" "$3.00" "qt/purple" . . 0 . "." 0 "$0.00" 9 "Saturday" "BEANS" "$3.00" "qt/mixed" 21 21 0 . "100%" 63 "$63.00" 9 "Saturday" "BEANS" "$3.00" "qt/pinto" . . 0 . "." 0 "$0.00" 9 "Saturday" "BEANS" "$3.00" "qt/lima" . . 0 . "." 0 "$0.00" 9 "Saturday" "BEETS" "$2.00" "bunch" 8 8 0 . "100%" 16 "$16.00" 9 "Saturday" "BEETS W/GRN" "$3.00" "bunch" 14 14 0 . "100%" 42 "$42.00" 9 "Saturday" "BEET GREENS" "$2.00" "bunch" . . 0 . "." 0 "$0.00" 9 "Saturday" "BOK CHOI" "$2.00" "head" . . 0 . "." 0 "$0.00" 9 "Saturday" "BRAISING MIX" "$3.00" "bunch" . . 0 . "." 0 "$0.00" 9 "Saturday" "BROCCOLI" "$1.00" "head (small)" . . 0 . "." 0 "$0.00" 9 "Saturday" "BROCCOLI" "$2.00" "large" . . 0 . "." 0 "$0.00" 9 "Saturday" "BROC GREENS" "$3.00" "bunch" 1 1 0 . "100%" 3 "$3.00" 9 "Saturday"
Comment