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?
How to Keep ID's with earliest dates without Diagnosis and ID's with earliest dates with DiagnosisI have a dataset with almost 3 million patientadmissions over a timespan of several years. Every ID …
how to back-transform valuesDear Stata users, I have run a mixed model using a natural log-transformed dependent variable (eGFR…
Problem using bysort, egen, mean(), and weight togetherHello, I am doing my best to follow all the statalist guidelines. My apologies if I am still lackin…
area specific linear time trend codingthe data is monthly level data. Coding of the time index variables are as follows: Year: 2005-2018…
Univariate Diagnostic Accuracy commandsHello, I am trying to perform a univariate Diagnostic accuracy using 2x 2 values in STATA. As I have…
Subscribe to:
Post Comments (Atom)
0 Response to Generating ith date of year variable from day/month/year date variable?
Post a Comment