I have been at this for days, reading manuals and forum posts, trying to figure out why I'm unable to convert two date variables that I imported into STATA from an SPSS dataset. I'm no closer to the answer than I was when I first began my journey. Any help would be appreciated!
Here is what I know:
I was given an SPSS dataset (.sav) with many variables, two of which are supposed to be timestamps. All I know about these variables is that 1) their data types in SPSS were "Date," 2) SPSS treated them as scale data, and 3) all dates should be between January-May 2019 or January-May 2020. When I bring in the dataset using "import spss..., "the two variables come into STATA as type: double and format: 10.0g. Below is an example of what an observation looks like in the data editor view and the actual number.
I've no clue how to even interpret these numbers to identify what conversion would be necessary. I've tried the code below since I've seen it in so many forums as the solution to the problem. It ends with a blank column.
gen statadate = dofc((spssdate*1000) + tc(14oct1582 00:00))
format statadate %td
Does anyone have any idea of how I might proceed to convert these variables to a date in STATA?
Thanks!
Here is what I know:
I was given an SPSS dataset (.sav) with many variables, two of which are supposed to be timestamps. All I know about these variables is that 1) their data types in SPSS were "Date," 2) SPSS treated them as scale data, and 3) all dates should be between January-May 2019 or January-May 2020. When I bring in the dataset using "import spss..., "the two variables come into STATA as type: double and format: 10.0g. Below is an example of what an observation looks like in the data editor view and the actual number.
Editor View | Actual Number |
1.9e+12 | 1897171200000 |
gen statadate = dofc((spssdate*1000) + tc(14oct1582 00:00))
format statadate %td
Does anyone have any idea of how I might proceed to convert these variables to a date in STATA?
Thanks!
Comment