consecutive operations filter

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

consecutive operations filter

Rodrigo Briceño-2
Dear SPSS listers. I am working with an SPSS file that has as an
identifier a variable called number of operation. The file I'm working
with has something special: each operation is split in two different
operations. In the list attached operations 110108361 and 110108362
represent only one operation, but they count as two different (the
reason why this occur is that the operation involves two different
states: first of all a loan is provided and then when the loan must be
paid the reimburse of money is quantified, with interests, in the
second operation). What I need is to generate a new variable that
allows me to do a filter so I can avoid double counting with other
procedures that I should prepare. Any help is appreciated.

Num of operation        filter
110108361       1
110108362       0
110110786       1
110110787       0
110112004       1
110112005       0
110223534       1
110223535       0
110332353       1
110332354       0
110440373       1
110440374       0



--
Rodrigo Briceño
Economist
[hidden email]
MSN: [hidden email]
SKYPE: rbriceno1087

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: consecutive operations filter

Maguin, Eugene
Rodrigo,
So it look like the rule is that if the left most 8 digits are the same, the
records defined to be 'one' operation.  Given a set of records that are one
operation, the record with the lowest value for the ninth digit should have
a value of 1 for the filter variable. All remaining records in the set have
a value of 0 for the filter variable.

So let's say the number of operation, numop, is a string (or can be made
into one).

Sort cases by numop.
String #first8(a8).  /*  #first8 is a temporary variable.
Compute #first8=substr(numop,1,8).
Do if (#casenum eq 1 or #first8 ne lag(#first8)).
+  compute filter_var=1.
Else.
+  compute filter_var=0.
End if.

Gene Maguin

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Rodrigo Briceño
Sent: Friday, January 27, 2012 10:54 AM
To: [hidden email]
Subject: consecutive operations filter

Dear SPSS listers. I am working with an SPSS file that has as an
identifier a variable called number of operation. The file I'm working
with has something special: each operation is split in two different
operations. In the list attached operations 110108361 and 110108362
represent only one operation, but they count as two different (the
reason why this occur is that the operation involves two different
states: first of all a loan is provided and then when the loan must be
paid the reimburse of money is quantified, with interests, in the
second operation). What I need is to generate a new variable that
allows me to do a filter so I can avoid double counting with other
procedures that I should prepare. Any help is appreciated.

Num of operation        filter
110108361       1
110108362       0
110110786       1
110110787       0
110112004       1
110112005       0
110223534       1
110223535       0
110332353       1
110332354       0
110440373       1
110440374       0



--
Rodrigo Briceño
Economist
[hidden email]
MSN: [hidden email]
SKYPE: rbriceno1087

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: consecutive operations filter

David Marso
Administrator
If indeed, the task is to identify records with the same initial n-1 digits irrespective of length the following should suffice.
DATA LIST FREE /NumOfOp f.
BEGIN DATA
110108361       1
110108362       0
110110786       1
110110787       0
110112004       1
110112005       0
110223534       1
110223535       0
110332353       1
110332354       0
110440373       1
110440374       0
END DATA.
NUMERIC #NOP.
COMPUTE filter=TRUNC(NumOfOp/10) NE #NOP.
COMPUTE #NOP=TRUNC(NumOfOp/10).
EXE.

Gene Maguin wrote
Rodrigo,
So it look like the rule is that if the left most 8 digits are the same, the
records defined to be 'one' operation.  Given a set of records that are one
operation, the record with the lowest value for the ninth digit should have
a value of 1 for the filter variable. All remaining records in the set have
a value of 0 for the filter variable.

So let's say the number of operation, numop, is a string (or can be made
into one).

Sort cases by numop.
String #first8(a8).  /*  #first8 is a temporary variable.
Compute #first8=substr(numop,1,8).
Do if (#casenum eq 1 or #first8 ne lag(#first8)).
+  compute filter_var=1.
Else.
+  compute filter_var=0.
End if.

Gene Maguin

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Rodrigo Briceño
Sent: Friday, January 27, 2012 10:54 AM
To: [hidden email]
Subject: consecutive operations filter

Dear SPSS listers. I am working with an SPSS file that has as an
identifier a variable called number of operation. The file I'm working
with has something special: each operation is split in two different
operations. In the list attached operations 110108361 and 110108362
represent only one operation, but they count as two different (the
reason why this occur is that the operation involves two different
states: first of all a loan is provided and then when the loan must be
paid the reimburse of money is quantified, with interests, in the
second operation). What I need is to generate a new variable that
allows me to do a filter so I can avoid double counting with other
procedures that I should prepare. Any help is appreciated.

Num of operation        filter
110108361       1
110108362       0
110110786       1
110110787       0
110112004       1
110112005       0
110223534       1
110223535       0
110332353       1
110332354       0
110440373       1
110440374       0



--
Rodrigo Briceño
Economist
[hidden email]
MSN: [hidden email]
SKYPE: rbriceno1087

=====================
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
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?"