我知道用merge命令可以实现1:m的匹配,但是这个命令是需要日期是一一对应的,我现在日期的格式是字符型的yyyy-mm-dd,应该怎么把它转换成yyyy-q的季度格式来实现1:m的匹配呢?
或者不用转换成季度日期的话有没有其他匹配方法呢?
十分感谢!
主表数据
- [/size]
- [size=15px]* Example generated by -dataex-. To install: ssc install dataex[/size]
- [size=15px]clear[/size]
- [size=15px]input long stkcd str10 trddt double instihold[/size]
- [size=15px]2 "2011-03-31" 3505060771[/size]
- [size=15px]2 "2011-06-30" 4200094776[/size]
- [size=15px]2 "2011-09-30" 3765885429[/size]
- [size=15px]2 "2011-12-31" 4632876840[/size]
- [size=15px]2 "2012-03-31" 4460984875[/size]
- [size=15px]2 "2012-06-30" 5157505310[/size]
- [size=15px]2 "2012-09-30" 4794275700[/size]
- [size=15px]2 "2012-12-31" 5215752671[/size]
- [size=15px]2 "2013-03-31" 4837327210[/size]
- [size=15px]2 "2013-06-30" 5260787968[/size]
- [size=15px]end[/size]
- [size=15px]
匹配表数据
- * Example generated by -dataex-. To install: ssc install dataex
- clear
- input long stkcd str10 trddt double(dnshrtrd circulatedmarketvalue)
- 2 "2011-01-04" 188816123 96109192753
- 2 "2011-01-05" 125616280 96223413128
- 2 "2011-01-06" 79128446 96511722151
- 2 "2011-01-07" 144721563 97331416795
- 2 "2011-01-10" 129046684 95682212658
- 2 "2011-01-11" 134731238 98591419933
- 2 "2011-01-12" 135521972 98851547238
- 2 "2011-01-13" 58795894 97678000509
- 2 "2011-01-14" 88532157 98698280098
- 2 "2011-01-17" 119826663 92490273052
- end