I have a "date and time" variable (clock variable is the right terminology?)
1. I would like to keep only observations for 2016. Do I have to created a year variable first and then keep 2016 or can I keep 2016 observations using this clock date variable? I tried the code below but it didn't work.
2. By the same token, can I keep only observations after a specific date (regardless of time) using this variable or I have to create a date variable first? For example, I created a date variable and then:
Finally, can I use this variable to keep a specific month- or again- I have to create a month variable first.
Thank you,
Marvin
Code:
. list OCCURED_DT in 1/1 +--------------------+ | OCCURED_DT | |--------------------| 1. | 28jun2016 21:20:00 | +--------------------+ . des OCCURED_DT storage display value variable name type format label variable label ----------------------------------------------------------------------------------------------------------------------------------------------------- OCCURED_DT double %tc
Code:
keep if yofd(OCCURED_DT) == 2016
Code:
keep if OCCURED_DT_DATEONLY >= td(28may2016)
Thank you,
Marvin