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
Dropping duplicated results with panel dataHello Stata people, I have a panel dataset where the cross-sectional variable is wage (for differen…
Binary Probit Model with Sample Selection Specification TestingHello Statalist, I am investigating the determinants of participation and contributions to pensions…
Panel data - xtline scaling issueHello, I am running a fixed effects regression for my panel data (xtset regions year). I have 10 reg…
Random Sample of two main groups consisting 5 subgroupsHi, I would like to select random sample from my data set on following conditions Two sites site A=…
loans/portfolio/partnersHi all, I have data that looks like the following Loan_ID Loan_date Lender_ID Lead_lender Borrow…
Subscribe to:
Post Comments (Atom)
0 Response to Generating a date variable from a numeric variable after a reshape
Post a Comment