CreatingDateVariableBySelectingDatesFromAnotherDateVariable

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

CreatingDateVariableBySelectingDatesFromAnotherDateVariable

Mome Mukherjee
Hi Listers

Is there any syntax which creates a date variable and inputs value from
another date variable when it meets a certain condition. Example,

PatientNum      DateTransfused    FirstTransfused
1501                            06-Jun-01       1
1340                            19-Jun-01       1
1340                            19-Jun-01       0
1351                            29-Jun-01       1
1351                            09-Jul-01        0
1351                            10-Jul-01        0
1351                            11-Jul-01        0

So a command for, when FirstTransfused=1, FirstDate=DateTransfused.

I dont want to create a numeric or string variable and manually change
it to date variable in 'variable view'.

Thanks a LOT in advance.

--
Mome
Reply | Threaded
Open this post in threaded view
|

Re: CreatingDateVariableBySelectingDatesFromAnotherDateVariable

Florio Arguillas
Try this one.

data list fixed/ PatientNum 1-4 DateTransfused 6-14 (date)  FirstTransfused 16.
begin data.
1501 06-Jun-01 1
1340 19-Jun-01 1
1340 19-Jun-01 0
1351 29-Jun-01 1
1351 09-Jul-01 0
1351 10-Jul-01 0
1351 11-Jul-01 0
end data.

numeric FirstDate (date9).
IF FirstTransfused = 1 FirstDate = DateTransfused.
LIST.



At 10:11 AM 10/11/2007, Mome Mukherjee wrote:

>Hi Listers
>
>Is there any syntax which creates a date variable and inputs value from
>another date variable when it meets a certain condition. Example,
>
>PatientNum      DateTransfused    FirstTransfused
>1501                            06-Jun-01       1
>1340                            19-Jun-01       1
>1340                            19-Jun-01       0
>1351                            29-Jun-01       1
>1351                            09-Jul-01        0
>1351                            10-Jul-01        0
>1351                            11-Jul-01        0
>
>So a command for, when FirstTransfused=1, FirstDate=DateTransfused.
>
>I dont want to create a numeric or string variable and manually change
>it to date variable in 'variable view'.
>
>Thanks a LOT in advance.
>
>--
>Mome
Reply | Threaded
Open this post in threaded view
|

Re: CreatingDateVariableBySelectingDatesFromAnotherDateVariable

Fry, Jonathan B.
If that does not give you quite what you wanted, try adding the command

    leave FirstData.

before the LIST command.

Jonathan Fry
SPSS Inc.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Florio Arguillas
Sent: Thursday, October 11, 2007 10:28 AM
To: [hidden email]
Subject: Re: CreatingDateVariableBySelectingDatesFromAnotherDateVariable

Try this one.

data list fixed/ PatientNum 1-4 DateTransfused 6-14 (date)  FirstTransfused 16.
begin data.
1501 06-Jun-01 1
1340 19-Jun-01 1
1340 19-Jun-01 0
1351 29-Jun-01 1
1351 09-Jul-01 0
1351 10-Jul-01 0
1351 11-Jul-01 0
end data.

numeric FirstDate (date9).
IF FirstTransfused = 1 FirstDate = DateTransfused.
LIST.



At 10:11 AM 10/11/2007, Mome Mukherjee wrote:

>Hi Listers
>
>Is there any syntax which creates a date variable and inputs value from
>another date variable when it meets a certain condition. Example,
>
>PatientNum      DateTransfused    FirstTransfused
>1501                            06-Jun-01       1
>1340                            19-Jun-01       1
>1340                            19-Jun-01       0
>1351                            29-Jun-01       1
>1351                            09-Jul-01        0
>1351                            10-Jul-01        0
>1351                            11-Jul-01        0
>
>So a command for, when FirstTransfused=1, FirstDate=DateTransfused.
>
>I dont want to create a numeric or string variable and manually change
>it to date variable in 'variable view'.
>
>Thanks a LOT in advance.
>
>--
>Mome