How to generate monthly in Stata, Creating Monthly Variable in Stata
In Stata you can generate monthly with the format tm().
clear all
set obs 100
gen month = tm(2021m1) + _n-1
format %tm month
Explain:
clear all is remove all data, value labels, matrices, scalars, constraints, clusters, stored results, frames, sersets, and Mata functions and objects from memory
set obs 100 is set observation to 100
gen is generate new variable
tm is function to make typing monthly dates.
tm(2021m1) + _n-1 the month start in 1/2021 and increasing by 1 month.
Comments
Post a Comment