Hi all,
I am wondering if it is possible to generate a variable in the format of ith day of the year from a date variable. I have been reading about working with date variables in Stata, but have yet to find a solution to this problem.
So, using a small subset of the data for an example, I have:
date
07oct2003
01apr2005
07oct2003
30oct2003
01apr2005
01apr2005
29dec2003
30oct2003
30oct2003
01apr2005
And I am hoping to create a variable with values of:
day_of_year
280
91
280
303
91
91
363
303
303
91
I understand that this is complicated by leap years (2000, 2004, etc.), but I am hoping that Stata can automatically account for that somehow...
Any advice you might be able to offer would be greatly appreciated!
Best wishes,
Matt
Related Posts with Generating ith date of year variable from day/month/year date variable?
Unconditional cross-nested 4-level modelDear all, I would like to replicate a paper (https://onlinelibrary.wiley.com/doi/10.1002/smj.3057) …
Dropping observations based on a list of IDHello, Is there a way to drop observations using a list of IDs ? I have a dataset and there are sev…
How to Modify Stata Data (Dta file) using python code and save changes back to the dta fileI have 2000 observations and 100 variables in my data from an empirical research project. I am curre…
By ID_number, keep registry-based (baseline=0) test dates obtained 1 year after original (baseline=1) study’s test dateReally need help! With the expert guidance of a statistician, I merged (using the append command) a …
ARDL modelHow to estimate a ARDL model with interaction variables ? First, i used the PCA method to generate t…
Subscribe to:
Post Comments (Atom)
0 Response to Generating ith date of year variable from day/month/year date variable?
Post a Comment