| Date: | Thu, 12 May 2011 15:06:50 -0400 |
| Reply-To: | Richard Ristow <wrristow@mindspring.com> |
| Sender: | "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU> |
| From: | Richard Ristow <wrristow@mindspring.com> |
| Subject: | Re: String Matches |
|
|
| In-Reply-To: | <1305224763403-4391106.post@n5.nabble.com> |
| Content-Type: | text/plain; charset="us-ascii"; format=flowed |
|---|
At 02:26 PM 5/12/2011, JKRockStomper wrote:
>Usually the arrest field is whatever the police officer enters into
>the computer. Here are some nicer examples:
>001 COUNTS OF UNDER INFLUENCE CNTL SUB 001 COUNTS OF VANDALISM -$400
>001 COUNTS OF PETTY THEFT RETAIL/ETC 001 COUNTS OF THEFT 001 COUNTS
>OF USE/UNDER INFL CONTRLD SU BENCH WARRANT #476195 / 001 COUNTS OF
>INF CORP INJ,SPOUSE/COHAB - F BENCH WARRANT #616250 / 001 COUNTS OF
>DRIVE,LIC SUSPENDED/ETC - M BENCH WARRANT #476195 / 001 COUNTS OF
>INFLICT CRPL INJ SP/COHAB - F TRANSPORT/SELL NARC CONT SUB F
>DISORDERLY CONDUCT PROSTITUTION M POSS COCAINE BASE SALE WRT 410341
>- F DISTURB PEACE WRT #410341 - M 001 COUNTS OF POSS-PUR COKE BASE
>F-SALE - F 001 COUNTS OF REC KNWN STOLN PROP $400 PLUS - F 01 COUNTS
>OF POSSESS BURGLARY TOOLS 001 COUNTS OF VIO ORD,PREVNT DOMES VIOL M
>BENCH WARRANT #129503 / 001 COUNTS OF POS/PUR F/SALE NARC/C/SUB - F
>00067F PREVENT/DISUADE WITNESS/VICTIM F/REPORTING CRIM 09611F
>PROBATION VIOLATION BENCH WARRANT #469182 / 001 COUNTS OF FORCE/ADW
>NOT FIREARM,GBI - F BENCH WARRANT #476195 INFLICT CRPL INJ SP/COHAB
>F 001 COUNTS OF POSS/PUR COKE BASE F/SALE - F 001 COUNTS OF POSS/PUR
>COKE BASE F/SALE-F 001 COUNTS OF DRIVE,LIC SUSPENDED/ETC M
One thing that may be going for you is that each charge seems to begin with
"001 COUNTS OF"
presumably allowing for more than one count as well. That should let
you separate the text into the individual charges.
>The current code looks something like this to figure out a few of
>the NCIC codes.
>IF INDEX(arstliteral,"TREAS0N") >0
> AND INDEX(arstliteral,"MISPRIS0N") =0 NCIC =0101.
>IF INDEX(arstliteral,"TREASON") >0
> AND INDEX(arstliteral,"MISPRISON") >0 NCIC =0102 .
>IF INDEX(arstliteral,"TREAS0N") >0
> AND INDEX(arstliteral,"MISPRIS0N") >0 NCIC =0102. IF
> INDEX(arstliteral,"ESPION") >0 NCIC =0103. IF
> INDEX(arstliteral,"ESPI0N") >0 NCIC =0103. IF
> INDEX(arstliteral,"SABOT") >0 NCIC =0104 . IF
> INDEX(arstliteral,"SAB0T") >0 NCIC =0104 . IF
> INDEX(arstliteral,"SEDIT") >0 NCIC =0105 . IF
> INDEX(arstliteral,"SELECT") >0 AND INDEX(arstliteral,"SERV") >0
> NCIC=0106 . IF INDEX(arstliteral,"SELECT") >0 AND
> INDEX(arstliteral,"SRVC") >0 NCIC=0106. IF
> INDEX(arstliteral,"SOVER") >0 NCIC =0199. IF
> INDEX(arstliteral,"S0VER") >0 NCIC =0199.
I trust that the actual coded is laid out more like the first few
lines that I've reformatted; the completely-wrapped code you sent is
very difficult indeed to read, let alone debug. (Notice that the test
for "TREASON" and "MISPRISON" occurs twice in the code you sent.)
It does seem you're interested in groups of offenses. Laying aside
the question of parsing into individual charges, the following would
run noticeably faster than a sequence of Ifs, and I think be easier
to understand as well.
DO IF INDEX(arstliteral,"TREAS0N") >0.
. DO IF INDEX(arstliteral,"MISPRIS0N") =0
. COMPUTE NCIC = 0101.
. ELSE.
. COMPUTE NCIC = 0102.
. END IF.
END IF.
Calls to the INDEX function are probably slow, and taking up much of
your time. The above code has at most two INDEX calls, and in many
cases only one. The corresponding IF statements,
IF INDEX(arstliteral,"TREAS0N") >0
AND INDEX(arstliteral,"MISPRIS0N") =0 NCIC =0101.
IF INDEX(arstliteral,"TREASON") >0
AND INDEX(arstliteral,"MISPRISON") >0 NCIC =0102 .
have four INDEX calls for every case.
-Onward,
Richard
=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (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
|