I am working with a table that includes all charges associated with inmates booked into our county jail; therefore, the unit of count is charges. Regretably, rather than use a "comments" variable the case management system uses the ChargeCode and ChargeDescription variables (both are String) to identify comments and make comments.
For example, the records below reflect one inmate, with two different bookings (admissions) into the county jail for drug charges. InmateID BookingNumber BookingDate ChargeCount ChargeCode ChargeDescription ChargeSquence 001 201312 09-JAN-2013 1 934.1 Cocaine Possession 1223454 001 201312 09-JAN-2012 1 934.2 Cocaine Trafficking 1223455 001 201367 09-JAN-2012 0 * Failure to Appear 1223456 001 201344 12-JAN-2013 1 934.1 Cocaine Possession 5345677 001 201344 12-JAN-2012 0 * to Appear in CourtA 5345678 001 201378 12-JAN-2012 0 * before Judge Dread 5345679 I would like to take the comments from the ChargeDescription var and restructure the data so that they appear with the corresponding booking (admissions) as a Comments variable. For simplicity and space I have excluded BookingNumber ChargeCount and ChargeSequence. I understand that with the restructing some values may be excluded. New Structure: InmateID BookingDate ChargeCode ChargeDescription Comment 001 09-JAN-2013 934.1 Cocaine Possession Failure to Appear 001 09-JAN-2012 934.2 Cocaine Trafficking Failure to Appear 001 12-JAN-2013 934.1 Cocaine Possession to Appear in CourtA - before Judge Dread I've explored and tried CASETOVARS from previous syntax provided by David M and others, however, I have had little luck. Let me know if you have any questions concerning my lengthly post. Any suggested syntax would be greatly appreciated. Sincerely, Damir |
This is an instance where Here I changed your
This is an unfortunate way for your database to hold information. But hopefully this helps! |
In reply to this post by DKUKEC
Thank you Andy,
This worked. Take care, Damir |
Administrator
|
In reply to this post by DKUKEC
SAVE the comment rows into a separate file.
Apply CASESTOVARS to that file. Concatenate the relevant fields. Match this as a TABLE back to the original. Fini.
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
|
ie:
(Using Andy's DATA LIST with mods for dinosaur version). DATA LIST LIST / InmateID (A3) BNumber (F6.0) BDate (DATE11) CCount (F1.0) CCode (F4.1) CDescr (A30) CSquence (F7.0). BEGIN DATA 001 201312 09-JAN-2013 1 934.1 "Cocaine Possession" 1223454 001 201312 09-JAN-2012 1 934.2 "Cocaine Trafficking" 1223455 001 201312 09-JAN-2012 0 * "Failure to Appear" 1223456 001 201344 12-JAN-2013 1 934.1 "Cocaine Possession" 5345677 001 201344 12-JAN-2012 0 * "to Appear in CourtA" 5345678 001 201344 12-JAN-2012 0 * "before Judge Dread" 5345679 END DATA. LIST. DO IF NOT MISSING(CCode). XSAVE OUTFILE 'C:\Trans.sav' . END IF. EXE. SELECT IF MISSING(CCode). MATCH FILES / FILE * / DROP CCount CCode CSquence. CASESTOVARS /ID = inmateid bnumber . STRING @ (A1). STRING COMMENT (A255). DO REPEAT V=cdescr.1 TO @. COMPUTE COMMENT = CONCAT(LTRIM(RTRIM(COMMENT))," ",V). END REPEAT. COMPUTE COMMENT = LTRIM(COMMENT). MATCH FILES / FILE 'C:\Trans.sav' /TABLE * / BY inmateid bnumber /DROP =cdescr.1 TO @. EXE.
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?" |
Thank you David.
Much appreciated.
From: David Marso [via SPSSX Discussion] [mailto:ml-node+[hidden email]]
ie: David Marso wrote SAVE the comment rows into a separate file.
DKUKEC wrote I am working with a table that includes all charges associated with inmates booked into our county jail; therefore, the unit of count is charges. Regretably, rather than use a "comments" variable the case management system uses the ChargeCode
and ChargeDescription variables (both are String) to identify comments and make comments.
Please reply to the list and not to my personal email.
If you reply to this email, your message will be added to the discussion below: http://spssx-discussion.1045642.n5.nabble.com/More-Data-Restructure-Questions-tp5717307p5717317.html To unsubscribe from More Data Restructure Questions,
click here. Under Florida law, e-mail addresses are public records. If you do not want your e-mail address released in response to a public records request, do not send electronic mail to this entity. Instead, contact this office by phone or in writing. |
I will be away from the office on Friday, January 11 with limited access to email. Will return on Monday, January 14. |
Free forum by Nabble | Edit this page |