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
Is there a way to tsset aggregated binomial data?Hi, I am wanting to do a segmented regression (as an interrupted time series) using binary outcome …
Regression without estimating the standard errorsDear All: I am currently estimating a series of regressions with fixed effects. However, the standa…
Optimize by minimizing the value of an equation to get a parameter value for each observationDear Everyone, Software Used: STATA 15.1 I am trying to get a parameter value (R) for each observa…
GMM Xtabond2Hi friends, This is my first experience for GMM. help me, please. I should examine the relationshi…
Difference in Difference with multiple treatment periods and multiple treatmentsGood day all! This is my first post on Stata list. Please let me know if any additional information …
Subscribe to:
Post Comments (Atom)
0 Response to Generating a date variable from a numeric variable after a reshape
Post a Comment