Hi, I have a *.sps file in which the first few lines are * Encoding: UTF-8. FILE HANDLE data1 NAME='EIG3TeacherRegDemoAn-TeacherRegistration_DATA_NOHDRS_2019-07-31_1113.csv' LRECL=90000. DATA LIST FREE FILE = data1 /teacher_id (F8.2) tr_site_id (F8.2) tr_district_id (F8.2) tr_school_id (F8.2) tr_cohort (F8.2)
tr_condition (F3) tr_withdraw_year (F3) tr_section (F3) tr_withdraw_date (SDATE10) tr_staff_id (A1000)
teacher_registration_form_complete (F3). The appearance of the dates in the csv file is M/DD/YYYY for January through September and MM/DD/YYYY for October through December I have a second *.sps file in which the first few lines are FILE HANDLE data1 NAME='EIG3StaffSurvey20172_DATA_NOHDRS_2019-06-05_1708.csv' LRECL=90000. DATA LIST FREE FILE = data1 /psw4_id (A1000) redcap_survey_identifier (A1000) ei_project_staff_demographic_survey_timestamp (A1000) psw4_date (SDATE10) psw4_dob (SDATE10)
psw4_gender (F3) psw4_race (F3) psw4_degree___1 (F3) psw4_degree___2 (F3) psw4_degree___3 (F3) psw4_degree___4 (F3) psw4_degree___5 (F3)
psw4_degree___6 (F3) psw4_assoc_major (A1000) psw4_bach_major (A1000) psw4_mast_major (A1000) psw4_eds_major (A1000) psw4_doc_major (A1000)
. . . psw4_coa_train_des (A30000) psw4_recipient (F3) psw4_adultlearn (F3) psw4_assessments (F3) psw4_assess_train (F3) ei_project_staff_demographic_survey_complete (F3). The appearance of the dates in the csv file is again M/DD/YYYY for January through September and MM/DD/YYYY for October through December When I read the first csv file SPSS produces an error message in regard to SDATE10 and sets tr_withdraw_date to missing. Changing SDATE10 to ADATE10 solves the problem. SPSS reads the dates in the second file without an error message. Is Encoding: UTF-8 the source of the problem in the first *.sps file? If not, what cause the problem in the first *.sps file.
Thanks, Jamie In anaother file James Algina Emeritus Professor Research and Evaluation Methodology 2-265M Norman Hall P.O. Box 117047 University of Florida Gainesville, FL 32611 |
This would not be related to the UTF8 encoding. SDATE format is yy/mm/dd or yyyy/mm/dd, separators optional, so it is wrong for M/DD/YYYY On Thu, Aug 1, 2019 at 12:01 PM Algina,James J <[hidden email]> wrote:
|
Hello John, Thank you for your response. If UTF-8 is the source of the problem, the question is why did SDATE10 fail to work in reading one file in which the dates in the csv file were M/DD/YYYY
for January through September and MM/DD/YYYY for October through December but worked in reading another in which the dates in the csv file were M/DD/YYYY and MM/DD/YYYY? Jamie James Algina Emeritus Professor Research and Evaluation Methodology 2-265M Norman Hall P.O. Box 117047 University of Florida Gainesville, FL 32611 From: SPSSX(r) Discussion [mailto:[hidden email]]
On Behalf Of Jon Peck This would not be related to the UTF8 encoding.
SDATE format is yy/mm/dd or yyyy/mm/dd, separators optional, so it is wrong for M/DD/YYYY On Thu, Aug 1, 2019 at 12:01 PM Algina,James J <[hidden email]> wrote:
===================== To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
|
I think Jon said the problem is not related to UTF encoding. The problem is using SDATE format to read a date that is in ADATE format. It's theoretically possible for ADATE format dates to be read without error in SDATE format, but the results would be wrong. For example 10/11/12 is valid in both formats, but means something very different. In SDATE format it's November 12, 2010. In ADATE format it's October 11, 2012. If one of the values is out of range for that format, you would get an error. For example 10/11/2012 would be invalid in SDATE format. On Thu, Aug 1, 2019 at 5:05 PM Algina,James J <[hidden email]> wrote:
|
In reply to this post by James Algina
Open the .csv file and check the date format and that the separator is '/'. I
very often find the separator to be '-' which will generate an error: /A field to be read under the SDATE format is invalid. The field must contain year, month, and day separated by spaces, dashes, slashes, decimal points, or commas. The result has been set to the system-missing value./ You have '-' separators in your file name in the FILE HANDLE syntax... Have you checked the date ranges in parts? SDATE can be YY/MM/DD (or YYYY/MM/DD) and if no values are greater than 12 ANY variation of DD, MM, and YY will work (generating VERY different resulting dates!). YYYY/MM/DD is also possible but then YYYY cannot be <1582... I assume you have an EXECUTE following the DATA LIST command. For some incomprehensible reason SPSS does not recognize ISO 8601 date formats <https://en.wikipedia.org/wiki/ISO_8601> (although it accepts date+time in ISO format). Handling transferred date values can be frustrating. HTH/PR James Algina wrote > Hello John, > Thank you for your response. If UTF-8 is the source of the problem, the > question is why did SDATE10 fail to work in reading one file in which the > dates in the csv file were M/DD/YYYY for January through September and > MM/DD/YYYY for October through December but worked in reading another in > which the dates in the csv file were M/DD/YYYY and MM/DD/YYYY? > Jamie > > James Algina > Emeritus Professor > Research and Evaluation Methodology > 2-265M Norman Hall > P.O. Box 117047 > University of Florida > Gainesville, FL 32611 > > From: SPSSX(r) Discussion [mailto: > SPSSX-L@.UGA > ] On Behalf Of Jon Peck > Sent: Thursday, August 01, 2019 4:47 PM > To: > SPSSX-L@.UGA > Subject: Re: Reading Dates > > This would not be related to the UTF8 encoding. SDATE format is yy/mm/dd > or yyyy/mm/dd, separators optional, so it is wrong for M/DD/YYYY > > On Thu, Aug 1, 2019 at 12:01 PM Algina,James J < > algina@ > <mailto: > algina@ > >> wrote: > Hi, > > I have a *.sps file in which the first few lines are > > * Encoding: UTF-8. > FILE HANDLE data1 > NAME='EIG3TeacherRegDemoAn-TeacherRegistration_DATA_NOHDRS_2019-07-31_1113.csv' > LRECL=90000. > DATA LIST FREE > FILE = data1 > /teacher_id (F8.2) tr_site_id (F8.2) tr_district_id (F8.2) > tr_school_id (F8.2) tr_cohort (F8.2) > tr_condition (F3) tr_withdraw_year (F3) tr_section (F3) > tr_withdraw_date (SDATE10) tr_staff_id (A1000) > teacher_registration_form_complete (F3). > > The appearance of the dates in the csv file is M/DD/YYYY for January > through September and MM/DD/YYYY for October through December > > I have a second *.sps file in which the first few lines are > > FILE HANDLE data1 > NAME='EIG3StaffSurvey20172_DATA_NOHDRS_2019-06-05_1708.csv' LRECL=90000. > DATA LIST FREE > FILE = data1 > /psw4_id (A1000) redcap_survey_identifier (A1000) > ei_project_staff_demographic_survey_timestamp (A1000) psw4_date (SDATE10) > psw4_dob (SDATE10) > > psw4_gender (F3) psw4_race (F3) psw4_degree___1 (F3) psw4_degree___2 (F3) > psw4_degree___3 (F3) psw4_degree___4 (F3) psw4_degree___5 (F3) > psw4_degree___6 (F3) psw4_assoc_major (A1000) psw4_bach_major (A1000) > psw4_mast_major (A1000) psw4_eds_major (A1000) psw4_doc_major (A1000) > . > . > . > psw4_coa_train_des (A30000) psw4_recipient (F3) psw4_adultlearn (F3) > psw4_assessments (F3) psw4_assess_train (F3) > ei_project_staff_demographic_survey_complete (F3). > > The appearance of the dates in the csv file is again M/DD/YYYY for January > through September and MM/DD/YYYY for October through December > > When I read the first csv file SPSS produces an error message in regard to > SDATE10 and sets tr_withdraw_date to missing. Changing SDATE10 to ADATE10 > solves the problem. > > SPSS reads the dates in the second file without an error message. > > Is Encoding: UTF-8 the source of the problem in the first *.sps file? If > not, what cause the problem in the first *.sps file. > > Thanks, > > Jamie > > > In anaother file > James Algina > Emeritus Professor > Research and Evaluation Methodology > 2-265M Norman Hall > P.O. Box 117047 > University of Florida > Gainesville, FL 32611 > > ===================== To manage your subscription to SPSSX-L, send a > message to > LISTSERV@.UGA > <mailto: > LISTSERV@.UGA > > (not to SPSSX-L), with no body text except the command. To leave the > list, send the command SIGNOFF SPSSX-L For a list of commands to manage > subscriptions, send the command INFO REFCARD > ===================== To manage your subscription to SPSSX-L, send a > message to > LISTSERV@.UGA > <mailto: > LISTSERV@.UGA > > (not to SPSSX-L), with no body text except the command. To leave the > list, send the command SIGNOFF SPSSX-L For a list of commands to manage > subscriptions, send the command INFO REFCARD > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (not to SPSSX-L), with no body text except the > command. To leave the list, send the command > SIGNOFF SPSSX-L > For a list of commands to manage subscriptions, send the command > INFO REFCARD -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
From the CSR... Dashes, periods, commas, slashes, or blanks can be used as delimiters in the input [date] values. For example, with the DATE format, the following input forms are all acceptable: 28-OCT-90 28/10/1990 28.OCT.90 28 October, 1990 The displayed values, however, will be the same: 28-OCT-90 or 28-OCT-1990, depending on whether the specified width allows 11 characters in output. For version 24 and higher, delimiters can be omitted in input values for DATE, ADATE, EDATE, and SDATE. On Fri, Aug 2, 2019 at 6:30 AM PRogman <[hidden email]> wrote: Open the .csv file and check the date format and that the separator is '/'. I |
Free forum by Nabble | Edit this page |