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
Need help with creating first difference operator for regression - econometricsHi There Everyone. I hope you're all well. I had a question, I'm really lost - i need to create a f…
Collapsing data by both weighted and unweighted meansI have a dataset of ~100K, and I'd like to collapse the data for variable Alpha into its mean, and v…
Simple Binary Outcome QuestionHello, I am having a problem understanding a simple statement that I need to code in Stata. Define…
Need Help Appending a Column Using AsdocDear all, I am using Stata 16, on mac and have provided a sample of my dataset using dataex at the …
how to output the results from mata to stata variable?I want to store the reuslts "1", how to do that? Code: * Example generated by -dataex-. To install:…
Subscribe to:
Post Comments (Atom)
0 Response to Generating a date variable from a numeric variable after a reshape
Post a Comment