Given below is the original dataset
I wanted to generate a counter variable for days given, so I coded
after doing this, dates are no longer sorted normally like this:
what should I do to make counter function well like this?
"2009-01-01" - "1"
"2009-01-02" - "2"
...
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str12 TradingDate long stkcd str13 ShortName byte Filling double ClosePrice "2009-01-01" 1 "深发展A" 2 2.983 "2009-01-02" 1 "深发展A" 2 2.983 "2009-01-05" 1 "深发展A" 0 3.062 "2009-01-06" 1 "深发展A" 0 3.248 "2009-01-07" 1 "深发展A" 0 3.15 end
Code:
gen var=_n
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str12 TradingDate long stkcd str13 ShortName byte Filling double(ClosePrice day) "2009-09-14" 1 "深发展A" 0 6.93 1 "2009-03-25" 1 "深发展A" 0 4.982 2 "2009-06-12" 1 "深发展A" 1 6.306 3 "2009-03-12" 1 "深发展A" 0 4.767 4 "2009-04-07" 1 "深发展A" 0 5.25 5 end
"2009-01-01" - "1"
"2009-01-02" - "2"
...

Comment