I have a quarterly panel data of 20 countries from 2000q1-2012q4. When I import the excel file, both the variables (country and date) turns out to be string variables (appears red in data browser).
Here is the description of the two variables: (for ease of reference, I have dropped dependent and independent variables)
Then I use the following command to encode the string country variable and now it appears blue in data browser
1. Is it correct?
2. How to convert the date variable correctly? When I create a date variable, I do manage to create the correct date variable but it does not take into account that the data is a panel. Instead of restarting from 2000q1 it continues from 2012q4 (for example, when the first country is completed for the next one date become 2013q1 instead of 2000q1). Alternatively, can I just derive the date variable for the first ID and then keep copy/pasting for the remaining?
Date appears as follows:
Here is the description of the two variables: (for ease of reference, I have dropped dependent and independent variables)
Code:
. des Contains data obs: 1,040 vars: 2 size: 21,840 ------------------------------------------------------------------------------------------------------------- storage display value variable name type format label variable label ------------------------------------------------------------------------------------------------------------- country str14 %14s Country date str7 %9s Date -------------------------------------------------------------------------------------------------------------
Code:
. encode country, generate(country_n) . des country_n storage display value variable name type format label variable label ------------------------------------------------------------------------------------------------------------- country_n long %14.0g country_n
2. How to convert the date variable correctly? When I create a date variable, I do manage to create the correct date variable but it does not take into account that the data is a panel. Instead of restarting from 2000q1 it continues from 2012q4 (for example, when the first country is completed for the next one date become 2013q1 instead of 2000q1). Alternatively, can I just derive the date variable for the first ID and then keep copy/pasting for the remaining?
Date appears as follows:
Code:
list country date in 1/10 +----------------------+ | country date | |----------------------| 1. | Argentina 2000-q1 | 2. | Argentina 2000-q2 | 3. | Argentina 2000-q3 | 4. | Argentina 2000-q4 | 5. | Argentina 2001-q1 | |----------------------| 6. | Argentina 2001-q2 | 7. | Argentina 2001-q3 | 8. | Argentina 2001-q4 | 9. | Argentina 2002-q1 | 10. | Argentina 2002-q2 | +----------------------+
Comment