I have a data set which I've been able to read successfully using "file type mixed". The data consists of a 'header' record which indicates the start of an incident. Each incident has the same agency ID and case number; but can have a set of subsequent records which may vary. The header record also has a field (call it 'Format') which indicates that the records for this incident are in what we can call 'Format 1.' I haven't used this field in the past, since all the incidents have been in the same format since we began collecting data.
Now we have begun accepting a slightly different set of incident records. The Format field for this header record indicates that the records in the incident are somewhat different from those in Format 1. I'm wondering if I can have an "IF [Format = 1] .... ELSE [Format = 2]... " as part of the syntax, so SPSS will use a different 'file type mixed' for incidents which have Format 2? This is condensed version of the current syntax: file type mixed file = 'r:\ucrr\fbi\nibrs_dump20120921.dat' record = ibr_rec 5 (a) . Record type '1'. data list / format 1-4 ibr_rec 5 (a) action 6 (a) tapemo 7-8 tapeyr 9-12 city 13-16 ori 17-25(a) inc_num 26-37(a) Record type '2'. data list / ori 17-25(a) inc_num 26-37(a) off_code 38-40 (a) Record type '3'. data list / ori 17-25(a) inc_num 26-37(a) losstype 38(a) Record type '4'. data list / ori 17-25(a) inc_num 26-37(a) vic_num 38-40 Record type '5'. data list / ori 17-25(a) inc_num 26-37(a) ofnseq 38-39 record type '6'. data list / ori 17-25(a) inc_num 26-37(a) arrseq 38-39 record type '7'. data list / ori 17-25(a) arrtrans 26-37(a) arrseq 38-39 end file type. Thanks for any advice. Daniel Bibel Massachusetts State Police Crime Reporting Unit 124 Acton Street Maynard, MA 01754 978-451-3731 (voice) 978-451-3707 (fax) ===================== 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 |
Administrator
|
"I'm wondering if I can have an "IF [Format = 1] ....
ELSE [Format = 2]... " as part of the syntax, so SPSS will use a different 'file type mixed' for incidents which have Format 2?". AFAIK not possible with FILE TYPE .... You will want to convert your FILE TYPE code to an INPUT PROGRAM! FILE TYPE is merely a wrapper for INPUT PROGRAM!
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
At 08:59 AM 9/11/2014, David Marso wrote:
>You will want to convert your FILE TYPE code to an INPUT >PROGRAM! FILE TYPE is merely a wrapper for INPUT PROGRAM! Is there a way of recovering the INPUT PROGRAM code that FILE TYPE expands into? That would make your advice MUCH EASIER to FOLLOW! ===================== 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 |
FILE TYPE does not generate an explicit
input program.
Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: Richard Ristow <[hidden email]> To: [hidden email] Date: 09/12/2014 01:25 PM Subject: Re: [SPSSX-L] question about "file type mixed" Sent by: "SPSSX(r) Discussion" <[hidden email]> At 08:59 AM 9/11/2014, David Marso wrote: >You will want to convert your FILE TYPE code to an INPUT >PROGRAM! FILE TYPE is merely a wrapper for INPUT PROGRAM! Is there a way of recovering the INPUT PROGRAM code that FILE TYPE expands into? That would make your advice MUCH EASIER to FOLLOW! ===================== 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 ===================== 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 |
Administrator
|
In reply to this post by Richard Ristow
In my experience the bear about INPUT PROGRAM is having an unambiguous means of determining the end of a case! OTOH, the file described by OP doesn't seem amenable to being easily parsed with any other means.
---
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
In reply to this post by David Marso
OK, I'm trying to follow the advice given with no success.
I have a data set which has two similar but different case layouts. The file type for both is 'mixed' -- there are seven different record types in both; and both can have multiple counts of record types. Both set have one 'administrative' record (record type = 1). There is a variable in the administrative record (rdw) which can take two values (258 or 233). This variable indicates which format the other records in this case uses. When there was only a single format for the data, I used a 'file type mixed' syntax successfully. The syntax reads 'ibr_rec' to see which record format to use to read that record. Now I would like to be able to read the data file and understand I need to wrap the 'file type mixed' syntax in an 'input program'. But the manual and other stuff on the internet are not as helpful as I would like. Any advice welcome and appreciated! Here's the (partial) syntax I'm using: input program. data list file = 'x:\testnibrsdata.dat' / rdw 1-4. do if rdw = 258. file type mixed file = 'x:\ucrr\testnibrsdata.dat' record = ibr_rec 5 (a) . Record type '1'. data list / rdw 1-4 ibr_rec 5 (a) action 6 (a) tapemo 7-8 tapeyr 9-12 city 13-16 ori 17-25(a) Record type '2'. data list / ori 17-25(a) inc_num 26-37(a) off_code 38-40 (a) end file type. else if rdw = 233. file type mixed file = 'x:\ucrr\testnibrsdata.dat' record = ibr_rec 5 (a) . Record type '1'. data list / rdw 1-4 ibr_rec 5 (a) action 6 (a) tapemo 7-8 tapeyr 9-12 city 13-16 ori 17-25(a) Record type '2'. data list / ori 17-25(a) inc_num 26-37(a) off_code 38-40 (a) end file type. end if. end input program. As always, thanks for the help or pointers. Daniel Bibel Massachusetts State Police Crime Reporting Unit 124 Acton Street Maynard, MA 01754 978-451-3731 (voice) 978-451-3707 (fax) -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso Sent: Thursday, September 11, 2014 8:59 AM To: [hidden email] Subject: Re: question about "file type mixed" "I'm wondering if I can have an "IF [Format = 1] .... ELSE [Format = 2]... " as part of the syntax, so SPSS will use a different 'file type mixed' for incidents which have Format 2?". AFAIK not possible with FILE TYPE .... You will want to convert your FILE TYPE code to an INPUT PROGRAM! FILE TYPE is merely a wrapper for INPUT PROGRAM! ----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/question-about-file-type-mixed-tp5727219p5727221.html Sent from the SPSSX Discussion mailing list archive at 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 ===================== 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 |
Administrator
|
"Now I would like to be able to read the data file and understand I need to wrap the 'file type mixed' syntax in an 'input program'. "
Not exactly! You will need to write an INPUT PROGRAM which does similar things as FILE TYPE. ie handle end of case processing etc... Maybe post a few complete sample cases so we can see what you are actually working with?
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
In reply to this post by Bibel, Daniel (POL)
02581I082014 MA007180014-10865-OF 20140831 22N TRACY ST
00652I082014 MA007180014-10865-OF 13BCN 20 40 8888 01344I082014 MA007180014-10865-OF 00113B I29 FWHR M 01SE 00455I082014 MA007180014-10865-OF 0131 MW 02581I082014 MA007180014-10864-OF 20140831 21N TAYLOR ST 00652I082014 MA007180014-10864-OF 290CN 13 8888 03073I082014 MA007180014-10864-OF 403000005000 01344I082014 MA007180014-10864-OF 001290 I52 MWHN 01PA 00455I082014 MA007180014-10864-OF 0133 FW 02581I082014 MA007180014-10862-OF 20140828 19N FLORIDA ST 00652I082014 MA007180014-10862-OF 290CN 13 8888 03073I082014 MA007180014-10862-OF 403000002000 01344I082014 MA007180014-10862-OF 001290 I33 FWNN 00 00455I082014 MA007180014-10862-OF 00 02231I072014 MA009110014005487 20140731 23N N WINDSOR ST CAMBRIDGE 00652I072014 MA009110014005487 13BCN 20 N 99 88 00652I072014 MA009110014005487 13CCN 20 N 88 00652I072014 MA009110014005487 23HCN 20 88 03073I072014 MA009110014005487 721000000400 01414I072014 MA009110014005487 00113B23H I46 FWUR N 01RU 01414I072014 MA009110014005487 00213C I46 FWUR 01RU 00465I072014 MA009110014005487 0149 MWN 01106I072014 MA009110014005487 01CAM20140161220140731TN13B01 49 MWNR 02231I072014 MA009110014005488 20140731 23N N MASSACHUSETTS AVE CAMBRIDGE 00652I072014 MA009110014005488 23HCN 13 88 03073I072014 MA009110014005488 738000000250 01414I072014 MA009110014005488 00123H I36 FWUN 00455I072014 MA009110014005488 00 Daniel Bibel Massachusetts State Police Crime Reporting Unit 124 Acton Street Maynard, MA 01754 978-451-3731 (voice) 978-451-3707 (fax) -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso Sent: Wednesday, October 08, 2014 10:23 AM To: [hidden email] Subject: Re: question about "file type mixed" "Now I would like to be able to read the data file and understand I need to wrap the 'file type mixed' syntax in an 'input program'. " Not exactly! You will need to write an INPUT PROGRAM which does similar things as FILE TYPE. ie handle end of case processing etc... Maybe post a few *complete* sample cases so we can see what you are actually working with? Bibel, Daniel (POL) wrote > OK, I'm trying to follow the advice given with no success. > I have a data set which has two similar but different case layouts. > The file type for both is 'mixed' -- there are seven different record > types in both; and both can have multiple counts of record types. > > Both set have one 'administrative' record (record type = 1). > > There is a variable in the administrative record (rdw) which can take > two values (258 or 233). This variable indicates which format the > other records in this case uses. > > When there was only a single format for the data, I used a 'file type > mixed' syntax successfully. The syntax reads 'ibr_rec' to see which > record format to use to read that record. > > Now I would like to be able to read the data file and understand I > need to wrap the 'file type mixed' syntax in an 'input program'. > > But the manual and other stuff on the internet are not as helpful as I > would like. Any advice welcome and appreciated! > > > Here's the (partial) syntax I'm using: > > input program. > data list file = 'x:\testnibrsdata.dat' / rdw 1-4. > do if rdw = 258. > file type mixed file = 'x:\ucrr\testnibrsdata.dat' > record = ibr_rec 5 (a) . > Record type '1'. > data list / > rdw 1-4 > ibr_rec 5 (a) > action 6 (a) > tapemo 7-8 > tapeyr 9-12 > city 13-16 > ori 17-25(a) > Record type '2'. > data list / > ori 17-25(a) > inc_num 26-37(a) > off_code 38-40 (a) > end file type. > else if rdw = 233. > file type mixed file = 'x:\ucrr\testnibrsdata.dat' > record = ibr_rec 5 (a) . > Record type '1'. > data list / > rdw 1-4 > ibr_rec 5 (a) > action 6 (a) > tapemo 7-8 > tapeyr 9-12 > city 13-16 > ori 17-25(a) > Record type '2'. > data list / > ori 17-25(a) > inc_num 26-37(a) > off_code 38-40 (a) > end file type. > end if. > end input program. > > > > As always, thanks for the help or pointers. > > > Daniel Bibel > Massachusetts State Police > Crime Reporting Unit > 124 Acton Street > Maynard, MA 01754 > 978-451-3731 (voice) > 978-451-3707 (fax) > > -----Original Message----- > From: SPSSX(r) Discussion [mailto: > SPSSX-L@.UGA > ] On Behalf Of David Marso > Sent: Thursday, September 11, 2014 8:59 AM > To: > SPSSX-L@.UGA > Subject: Re: question about "file type mixed" > > "I'm wondering if I can have an "IF [Format = 1] .... > ELSE [Format = 2]... " as part of the syntax, so SPSS will use a > different 'file type mixed' for incidents which have Format 2?". > > AFAIK not possible with FILE TYPE .... You will want to convert your > FILE TYPE code to an INPUT PROGRAM! FILE TYPE is merely a wrapper for > INPUT PROGRAM! > > > > ----- > Please reply to the list and not to my personal email. > Those desiring my consulting or training services please feel free to > email me. > --- > "Nolite dare sanctum canibus neque mittatis margaritas vestras ante > porcos ne forte conculcent eas pedibus suis." > Cum es damnatorum possederunt porcos iens ut salire off sanguinum > cliff in abyssum?" > -- > View this message in context: > http://spssx-discussion.1045642.n5.nabble.com/question-about-file-type > -mixed-tp5727219p5727221.html Sent from the SPSSX Discussion mailing > list archive at Nabble.com. > > ===================== > 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 > > ===================== > 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 ----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/question-about-file-type-mixed-tp5727219p5727543.html Sent from the SPSSX Discussion mailing list archive at 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 ===================== 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 |
In reply to this post by Bibel, Daniel (POL)
I'm spectating on this. That said, as I understand your syntax there is a two level structure to the records. A record is either rdw=258 or rdw=233 and each of those is either ibr_rec=1 or ibr_rec=2. An ibr_rec=1 record has different fields from an ibr_rec=2 record as your code shows. I don't see any difference between a rdw=258 record and a rdw=233 record. Is the added complexity needed?
Gene Maguin -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bibel, Daniel (POL) Sent: Wednesday, October 08, 2014 10:13 AM To: [hidden email] Subject: Re: question about "file type mixed" OK, I'm trying to follow the advice given with no success. I have a data set which has two similar but different case layouts. The file type for both is 'mixed' -- there are seven different record types in both; and both can have multiple counts of record types. Both set have one 'administrative' record (record type = 1). There is a variable in the administrative record (rdw) which can take two values (258 or 233). This variable indicates which format the other records in this case uses. When there was only a single format for the data, I used a 'file type mixed' syntax successfully. The syntax reads 'ibr_rec' to see which record format to use to read that record. Now I would like to be able to read the data file and understand I need to wrap the 'file type mixed' syntax in an 'input program'. But the manual and other stuff on the internet are not as helpful as I would like. Any advice welcome and appreciated! Here's the (partial) syntax I'm using: input program. data list file = 'x:\testnibrsdata.dat' / rdw 1-4. do if rdw = 258. file type mixed file = 'x:\ucrr\testnibrsdata.dat' record = ibr_rec 5 (a) . Record type '1'. data list / rdw 1-4 ibr_rec 5 (a) action 6 (a) tapemo 7-8 tapeyr 9-12 city 13-16 ori 17-25(a) Record type '2'. data list / ori 17-25(a) inc_num 26-37(a) off_code 38-40 (a) end file type. else if rdw = 233. file type mixed file = 'x:\ucrr\testnibrsdata.dat' record = ibr_rec 5 (a) . Record type '1'. data list / rdw 1-4 ibr_rec 5 (a) action 6 (a) tapemo 7-8 tapeyr 9-12 city 13-16 ori 17-25(a) Record type '2'. data list / ori 17-25(a) inc_num 26-37(a) off_code 38-40 (a) end file type. end if. end input program. As always, thanks for the help or pointers. Daniel Bibel Massachusetts State Police Crime Reporting Unit 124 Acton Street Maynard, MA 01754 978-451-3731 (voice) 978-451-3707 (fax) -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso Sent: Thursday, September 11, 2014 8:59 AM To: [hidden email] Subject: Re: question about "file type mixed" "I'm wondering if I can have an "IF [Format = 1] .... ELSE [Format = 2]... " as part of the syntax, so SPSS will use a different 'file type mixed' for incidents which have Format 2?". AFAIK not possible with FILE TYPE .... You will want to convert your FILE TYPE code to an INPUT PROGRAM! FILE TYPE is merely a wrapper for INPUT PROGRAM! ----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/question-about-file-type-mixed-tp5727219p5727221.html Sent from the SPSSX Discussion mailing list archive at 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 ===================== 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 ===================== 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 |
Administrator
|
In reply to this post by David Marso
I won't write an INPUT PROGRAM to your specifics for free, but here is an example I just created for managing data which roughly coincides with your situation.
NOTE/RANT to IMB/SPSS pubs. There used to be GREAT examples in the FM for reading COMPLEX files. NOW they all suck! What happened? How in the hell do you expect users to put together the pieces? ----------------------------------------- INPUT PROGRAM. DATA LIST END=#EOF/ r 1 . DO IF NOT (#EOF). + REREAD. + DATA LIST / ID 1 rectype 3 h1 to h3 5-7. + DO IF rectype=1. + DATA LIST RECORDS 2/r10_1 TO r10_7 1-7 /r11_1 r11_2 4-7. + ELSE IF rectype=2. + DATA LIST RECORDS 3/r20_1 TO r20_7 3-9 /r21_1 TO r21_3 3-8 /r22_1 TO r22_3 3-8. + END IF. + END CASE. ELSE. + END FILE. END IF. END INPUT PROGRAM. BEGIN DATA 1 1 345 3456789 1011 1 2 345 1234567 101112 131415 END DATA. LIST. I rect h h h r10 r10 r10 r10 r10 r10 r10 r D ype 1 2 3 _1 _2 _3 _4 _5 _6 _7 r11_1 r11_2 r20_1 r20_2 r20_3 r20_4 r20_5 r20_6 r20_7 r21_1 r21_2 r21_3 r22_1 r22_2 r22_3 1 1 1 3 4 5 3 4 5 6 7 8 9 10 11 . . . . . . . . . . . . . 1 1 2 3 4 5 . . . . . . . . . 1 2 3 4 5 6 7 10 11 12 13 14 15 Number of cases read: 2 Number of cases listed: 2
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Administrator
|
I have some old examples at the link below. I don't have time right now to go find the examples in the current documentation, so don't know if this is any better than what's there.
http://www.angelfire.com/wv/bwhomedir/spss/read_data_from_mixed_file.txt HTH.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
Administrator
|
In reply to this post by David Marso
Note a bit of fiddling results in a simplified version of my previous example:
INPUT PROGRAM. + DATA LIST / ID 1 rectype 3 h1 to h3 5-7. + DO IF rectype=1. + DATA LIST RECORDS 2/r10_1 TO r10_7 1-7 /r11_1 r11_2 4-7. + ELSE IF rectype=2. + DATA LIST RECORDS 3/r20_1 TO r20_7 3-9 /r21_1 TO r21_3 3-8 /r22_1 TO r22_3 3-8. + END IF. END INPUT PROGRAM. BEGIN DATA 1 1 345 3456789 1011 1 2 345 1234567 101112 131415 END DATA. LIST.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Free forum by Nabble | Edit this page |