« Return to Thread: creating new variables

Re: creating new variables

by abdelrhman elmubarak :: Rate this Message:

Reply to Author | View in Thread

Some parts of this message have been removed. Learn more about Nabble's security policy.
thanks Melissa
I am finding difficulty if there are more than one possible extra repair on the same day , your synatx work very fine if there are one repair on the same day...any help is higly appreciated.
thanks
Abdulrahman
 

Date: Thu, 7 May 2009 09:14:37 -0500
From: mives@...
Subject: Re: creating new variables
To: SPSSX-L@...

One way would be to use the sort function so that the 209 record is last.  (it may help to create a dichotomy for rep209=1 or 0 if not--something like this would be needed if there are >2 repairs in a day)
Then do a lag function to create morejobs and moremoney.
 
THE FOLLOWING ASSUMES that no client has >2 repairs in a day AND 209 is the highest repair value.
 
sort cases by id repdate reptype.
if (id=lag(id) and repdate=lag(repdate) and reptype=209) morejobs=1.
if ((id ne lag(id) or repdate ne lag(repdate)) and reptype=209) morejobs=0.
if (id=lag(id) and repdate=lag(repdate) and reptype=209) moremoney=lag(money).
 
 
The actual syntax will differ if there are more than one possible extra repairs on the same date (i.e. one id could have 3+ per day), but similar logic should work.
 
HTH,
Melissa 
 

From: SPSSX(r) Discussion [mailto:SPSSX-L@...] On Behalf Of abdelrhman elmubarak
Sent: Thursday, May 07, 2009 3:36 AM
To: SPSSX-L@...
Subject: [SPSSX-L] creating new variables


  

Hi

my data looks as below

 

id

Repair Date

Repair Type

money

16

20090430

115

23

30

20090325

209

45

30

20090124

103

62

47

20090409

209

78

47

20090409

101

69


 

I want to create two more variables for those  who  did repair type 209…the purpose is to know did they did more jobs on the same day of their visit and what the money generated from that ….at the final my data should be look as below

 

id

Repair Date

Repair Type

money

more jobs plus

more money plus

16

20090430

115

23

 

 

30

20090325

209

45

0

 

30

20090124

103

62

 

 

47

20090409

209

78

1

69

47

20090409

101

69

 

 


 

I can explain more if it is required

Thanks in advance

 

Abdulrahman

 


Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! Try it!

Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! Try it!

PRIVILEGED AND CONFIDENTIAL INFORMATION
This transmittal and any attachments may contain PRIVILEGED AND
CONFIDENTIAL information and is intended only for the use of the
addressee. If you are not the designated recipient, or an employee
or agent authorized to deliver such transmittals to the designated
recipient, you are hereby notified that any dissemination,
copying or publication of this transmittal is strictly prohibited. If
you have received this transmittal in error, please notify us
immediately by replying to the sender and delete this copy from your
system. You may also call us at (309) 827-6026 for assistance.


What can you do with the new Windows Live? Find out

 « Return to Thread: creating new variables