Hello.
I'm working with a dataset that looks like this:
company / numeric_date / v1 / v2 / .../ vk
A / 1 / .4 / .2 / ... / ..
A / 2 / .3 / .2 / ... / ..
A / .. / . / . / ... / ..
A / 60 / .6 / .3 / ... / ..
B / 1 / .4 / .2 / ... / ..
B / 2 / .4 / .2 / ... / ..
.. / ... / ... / .... / ... / ..
Z / 60 / .5 / .6 / ... / ..
As you can see, the dataset is a panel where I have Z companies (64) with information for k variables (5 variables) and a variable called 'numeric_date' which ranges from 1 to 60. This specific variable is the one I need to use to generate date variable with the following characteristics:
-the starting date is 01-01-2015, which corresponds to numeric_date==1
-the variable varies monthly, which means that with a marginal increase in numeric_date, the date should increase in one month. numeric_date==2, date= 02-01-2015
-this means that the value for numeric_date==60 is 12-01-2019
This outcome is the result of a reshape I made, with the following do-file:
clear
import excel "/Users/nicolasmorales/Downloads/export para stata reshape-2.xlsx", sheet("V21") firstrow clear
duplicates report company
duplicates tag entidad, gen(drop)
drop if drop>0
duplicates report company
drop drop
reshape long a b c d e f, i(company) j(numeric_date)
rename a v21
rename b v22
rename c v30
rename d v461
rename e roa
rename f v43
*here is where I need to generate the date variable
I thought of doing the process manually, by generating the date variable and replacing the 60 values one by one, but I figured there must be a more efficient way to do this process.
Any suggestions are much appreciated!!
Thank you
Related Posts with Generating a date variable from a numeric variable after a reshape
Fixed Effects: Variables Indexed by Country, Sector and TimeI am trying to run a regression for fixed effects specifications. The dependent variable is Volatili…
Question about spregdpdDear all, After we use xtabond or xtabond2, we can use "estat serial" to get AR(1) and AR(2) .But if…
Selecting a subset from a balanced panel data under certain conditionsDear all, I need some help. Well, I have a database in the structure of a balanced panel. I have to…
Lagged Dependent Variable (Panel)Is it appropriate to include the dependent variable as a control in an FE panel regression. Previous…
A few questions about my analysis in StataDear all, I am new on this forum, so I hope I'm posting these questions on the right place. I am n…
Subscribe to:
Post Comments (Atom)
0 Response to Generating a date variable from a numeric variable after a reshape
Post a Comment