Hi,
I have a month variable- in the form of a string. However, when I encode it, I do not get a categorical variable. I have tried the following the things:
1.
2.
There seems to be a special character "-" in a month that I cannot remove. The normal: destring month_f, gen(_month_) ignore("-") has not worked for me.
Example of the variable:
I have a month variable- in the form of a string. However, when I encode it, I do not get a categorical variable. I have tried the following the things:
1.
Code:
tab month_f if missing(real( month_f )) MONTH_F | Freq. Percent Cum. ------------+----------------------------------- Apr 2020 | 214,603 25.07 25.07 Apr-19 | 213,367 24.92 49.99 Aug 2019 | 213,885 24.98 74.97 Dec 2019 | 214,310 25.03 100.00 ------------+----------------------------------- Total | 856,165 100.00
Code:
. gen month_f1 = month_f . replace month_f1 = "" if trim( month_f1 )=="-" (0 real changes made)
Example of the variable:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str8 month_f "Apr-19" "Aug 2019" "Dec 2019" "Apr 2020" "Apr-19" "Aug 2019" "Dec 2019" "Apr 2020" "Apr-19" "Aug 2019" "Dec 2019" "Apr 2020" "Apr-19" "Aug 2019" "Dec 2019" "Apr 2020" "Apr-19" "Aug 2019" "Dec 2019" "Apr 2020" "Apr-19" "Aug 2019" "Dec 2019" "Apr 2020" "Apr-19" "Aug 2019" "Dec 2019" "Apr 2020" "Apr-19" "Aug 2019" "Dec 2019" "Apr 2020" "Apr-19" "Aug 2019" "Dec 2019" "Apr 2020" "Apr-19" "Aug 2019" "Dec 2019" "Apr 2020" "Apr-19" "Aug 2019" "Dec 2019" "Apr 2020" end
Comment