Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 72776

Extracting Date from DateTime Format

$
0
0
I have dates in the format: 12FEB1993:00:00:00.000 and would like to have a variable with just 12FEB1993 and, ultimately, 1993Q1. The step I am struggling with is just getting the date extracted from the DateTime value. I've read the help documentation and various discussions on this site but, when I use the suggested syntax (i.e. gen double time = monthly(date_start, "MDY"), the variable populates as all missing values.

. gen right = monthly(date_start, "MDY")
(310,401 missing values generated)


I'm thinking that there is a chance that Stata isn't reading the original string as a date variable or there is some step that should be conducted prior that I have been missing. Any help would be much appreciated.


Viewing all articles
Browse latest Browse all 72776

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>