Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str5 VARKYG291021031 float(VARKYG312361051 VARKYG314551014 VARKYG316231045 date) "35.05" 41.6 111.5 53.29 20727 "34.25" 43.65 113 52.7 20730 "34" 43.05 111 52.89 20731 "33.95" 43.1 113 53.58 20732 "34.3" 42.35 113 55.63 20733 "33.55" 41.65 109 53.87 20734 "NA" 41.65 109 53.87 20737 "NA" 40.8 107 50.75 20738 "32.7" 40.8 109.5 50.46 20739 "33" 41 109 49.58 20740 "32.5" 40 104.5 47.72 20741 "32.8" 41.1 103 47.58 20744 "32.95" 41.6 94.5 46.84 20745 "NA" 41.2 89.9 45.87 20746 "NA" 40.65 92.6 45.58 20747 "33.9" 40.8 91.9 44.89 20748 "33.5" 41.05 92.7 45.28 20751 "33.9" 40.9 91.9 44.89 20752 end format %tdNN/DD/CCYY date
I have tried the following code to replace "NA" to missing values (dots).
Code:
foreach var varlist VARKYG291021031-VARKYG316231045 { replace `var'=. if `var'==NA }
Any idea how to correct it?
Thank you.
0 Response to Loop to replace string variables
Post a Comment