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
Code blocks on this forum need fixingThe code blocks on this forum give weird output every now and then. Specifically, multi-line code is…
Small sample of 38 observationsHi, I have a panel data of 26 countries and 21 years, but I am only concerned with 38 observations.…
Change over timeHi all, I have a data-set of organizations and their service sites for 2014-2018. Organizations 1) o…
Conflicting results in did and dose response modelsDear All, I am looking to the impact of Syrian mass migration on the firm-level performance measure…
Generate/replace new variables in a repetitive way for all the individuals.Hello, everyone. Below is my data and variable name "salary21" means salary of PID 21, and each val…
Subscribe to:
Post Comments (Atom)
0 Response to Issue With Quarterly Data Format
Post a Comment