Hello Stata community,
I am having an issue when trying to create a simple "difference" variable, being the difference between two quarterly variables (e.g. 2003q2 and 2004q2 should have a difference of 4).
I have a dataset of over 300 variables, with 920,000 observations (formed by pairwise combination of groups). Each observation has two "year+quarter" variables, one being for the year and quarter of a financial report, the other being for the year and quarter of an event.
Both variables are floats, in the format of %tq. When I use the code "gen disdifference = yearquarter - disyrqtr1", the resulting difference variable is incorrect.
Below is the first 30 observations of the variables of interest. The minimum for disdifference is 111, when it should likely be 0 or 1.
| yearqu~r disyrq~1 disdif~e |
|--------------------------------|
1. | 2003q1 2016q3 154 |
2. | 2003q1 2017q2 153 |
3. | 2003q1 2009q3 161 |
4. | 2003q1 2006q3 164 |
5. | 2003q1 2017q4 151 |
|--------------------------------|
6. | 2003q1 2013q2 160 |
7. | 2003q1 2015q2 158 |
8. | 2003q1 2015q4 156 |
9. | 2003q1 2005q2 167 |
10. | 2003q1 2016q2 155 |
|--------------------------------|
11. | 2003q1 2015q3 157 |
12. | 2003q1 2003q2 171 |
13. | 2003q1 2004q4 168 |
14. | 2003q1 2009q3 161 |
15. | 2003q1 2015q3 157 |
|--------------------------------|
16. | 2003q1 2016q2 155 |
17. | 2003q1 2017q4 151 |
18. | 2003q1 2017q2 153 |r
19. | 2003q1 2004q4 168 |
20. | 2003q1 2015q2 158 |
|--------------------------------|
21. | 2003q1 2006q3 164 |
22. | 2003q1 2016q3 154 |
23. | 2003q1 2003q2 171 |
24. | 2003q1 2005q2 167 |
25. | 2003q1 2013q2 160 |
|--------------------------------|
26. | 2003q1 2015q4 156 |
27. | 2003q1 2016q2 155 |
28. | 2003q1 2015q4 156 |
29. | 2003q1 2015q2 158 |
30. | 2003q1 2005q2 167 |
+--------------------------------+
I suspect I am having an issue with the setting of time in the dataset, but have struggled to understand how to fix an issue.
I would be very grateful for advice.
Thanks,
Nick
Related Posts with Issue With Quarterly Data Format
Sample Selection with heteroHi All, I understand that in the presence of hetero the standard ML sample selection procedure (hec…
Marginsplot interpretationDear all on Statalist, I am posting to ask for your help on interpretation of marginsplot graph, es…
reg or xtreg for unbalanced panel data?Hi, I have an unbalanced panel dataset for 2000+ companies from 1992-2018. Following was the xtset …
psmatch2 and exact matchingHello all! I am trying to combine the psmatch2 command with exact matching. More specifically, I am…
Categorical VariablesHi all I am trying to find out the average of certain categorical variables. The variable Name_mat…
Subscribe to:
Post Comments (Atom)
0 Response to Issue With Quarterly Data Format
Post a Comment