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

converting string date to numeric and getting inconsistent result

$
0
0
I have a new data set with string date variable entered as DD/MM/YYYY (i.e., 05/24/1975).

The inconsistent date conversion results I'm getting in Stata is that only about half the cases in the date variable are converting, with the other half being blank and generating this error:
(26 missing values generated)
The syntax used (Stata 14; windows 7 sys)

Code:
gen date2 = date(birthdate, "DMY")
format date2 %td
Details:
The data was digitally "captured" from scanned (PDFs & TIFs) questionnaires (nd exported to Microsoft Access, then into Stata format via Stat/Transfer. The data capture software was "Remark Office OMR 2014". This is my first experience using Remark (FYI - mostly positive so far). I am working with a small sample of data (n=47).
  • The "birthdate" variable was entered manually into Remark as a "textual" variable (their term for alphanumeric variable).
  • In Access the birthdate variable properties are "Text" with filed size = 25; no input mask or other properties are set. I have confirmed that all birthdates are correctly entered (dd/mm/yyyy)
  • In Stata the birthdate variable is "str12" type , with format "%12s". All data in this variable looks as expected.
  • In Stata the new variable generated to convert birthdate to a numeric date (with half the cases successfully generated) is a "float" type with format "%tdCCYY-NN-DD"
I do not understand why only cases/rows #1 thru 21 will convert the date from strring to numeric date (with rows #22-47 left blank).

One other oddity: IN this small data set I manually inserted a new string variable and manually entered string dates in to the column. Then I tried to convert the new var string date to a new variable )using the same syntax as above. Surprisingly, only rows 1-21 were converted with rows 22-47 being blank, just like the imported variable.

Any suggestions as to what I am doing wrong? Could this be a Stata anomaly?

. . . or could the Remark software be embedding something I can't spot?

Thanks very much (in advance),
Wendy



Viewing all articles
Browse latest Browse all 73322

Trending Articles



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