Condition with time variable?

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

Condition with time variable?

Robert L

I can’t find out how to deal with time variables in transformations. The code I have started out with is

 

IF  DDate= 2006/12/05 temp=1.

 

But it doesn’t work. The same goes for

 

IF  (DDate=XDATE.DATE(2006/12/05)) temp=1.

 

Nothing happens, temp is simply filled with missing values. This should not be that difficult, should it?

 

Robert

Robert Lundqvist
Reply | Threaded
Open this post in threaded view
|

Re: Condition with time variable?

Maguin, Eugene

Gotta read up on date/time functions in the CSR.

 

*  assume mm/dd/yyyy date structure.

If (DDate eq date.mdy(12,5,2006) temp=1.

 

Gene maguin

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Robert Lundqvist
Sent: Monday, June 02, 2014 10:09 AM
To: [hidden email]
Subject: Condition with time variable?

 

I can’t find out how to deal with time variables in transformations. The code I have started out with is

 

IF  DDate= 2006/12/05 temp=1.

 

But it doesn’t work. The same goes for

 

IF  (DDate=XDATE.DATE(2006/12/05)) temp=1.

 

Nothing happens, temp is simply filled with missing values. This should not be that difficult, should it?

 

Robert

Reply | Threaded
Open this post in threaded view
|

Re: Condition with time variable?

David Marso
Administrator
They are actually quite simple once one has bothered to do a bit of RTFM!
3 types
Extraction, Aggregation, Conversion
XDATE.type(date)
DATE.type(args)
CTIME.type(value)
Then the recent IMNSHO clunky DATEDIFF(arg,arg,'scale')

Maguin, Eugene wrote
Gotta read up on date/time functions in the CSR.

*  assume mm/dd/yyyy date structure.
If (DDate eq date.mdy(12,5,2006) temp=1.

Gene maguin

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Robert Lundqvist
Sent: Monday, June 02, 2014 10:09 AM
To: [hidden email]
Subject: Condition with time variable?

I can't find out how to deal with time variables in transformations. The code I have started out with is

IF  DDate= 2006/12/05 temp=1.

But it doesn't work. The same goes for

IF  (DDate=XDATE.DATE(2006/12/05)) temp=1.

Nothing happens, temp is simply filled with missing values. This should not be that difficult, should it?

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

Re: Condition with time variable?

Rich Ulrich
In reply to this post by Robert L
In the syntax of SPSS and of most statistical languages,
the use of "/" is to indicate division; and if there are several
of them, they will be performed from left to right.  If you divide
by 12 and then divide by 5, you do the same as dividing by 60.

So, typing "2006/12/5"  has the same meaning as typing
"2006/60" ... which clearly has nothing to do with figuring DATES.

--
Rich Ulrich
 


Date: Mon, 2 Jun 2014 14:09:25 +0000
From: [hidden email]
Subject: Condition with time variable?
To: [hidden email]

I can’t find out how to deal with time variables in transformations. The code I have started out with is

 

IF  DDate= 2006/12/05 temp=1.

 

But it doesn’t work. The same goes for

 

IF  (DDate=XDATE.DATE(2006/12/05)) temp=1.

 

Nothing happens, temp is simply filled with missing values. This should not be that difficult, should it?

 

Robert

Reply | Threaded
Open this post in threaded view
|

Re: Condition with time variable?

Robert L
In reply to this post by Robert L
Problem solved, thanks Gene! I should have written in the original posting that I have read the manual, and I am aware of the XDATE.type functions (as well as the others). The intention, probably misguided, was  to phrase the question in a format as principally simple as possible. So I will make a new attempt to describe the question, what works and what doesn't.

*This works fine, the variable temp1 is set to numbers corresponding to the actual dates in the DDate variable (which has a date format, SDATE11 actually). So the xdate.date functions does it's job. It's a neat function too given that it seems to recognize most date formats without the need to specify the actual format.
COMPUTE temp1=xdate.date(DDate).

*This does not work, and shouldn't do so either. The DDate variable is obviously not possible to match with the
result from the xdate.date function (which would have given results in a numeric F8.2 format if it had worked out).
IF  (DDate=xdate.date(2007/10/26)) temp2=1.

*Then I first expected the following to work, with both parts converted to F8.2:
IF  (xdate.date(DDate)=xdate.date(2007/10/26)) temp2=1.
*But it doesn't. The argument to xdate is in this case not recognized as a date. Quite reasonably so.

*Using date.dmy works however!
IF DDate=date.dmy(27, 10, 2007) temp2=1

*And the following naturally works too:
IF  (xdate.date(DDate)=xdate.date(date.dmy(26, 10, 2007))) temp3=1.

My mistake was to mix up the xdate.type and the date.type functions, and the need to distinguish date extraction from date creation.

Robert


-----Ursprungligt meddelande-----
Från: SPSSX(r) Discussion [mailto:[hidden email]] För David Marso
Skickat: den 2 juni 2014 16:34
Till: [hidden email]
Ämne: Re: Condition with time variable?

They are actually quite simple once one has bothered to do a bit of RTFM!
3 types
Extraction, Aggregation, Conversion
XDATE.type(date)
DATE.type(args)
CTIME.type(value)
Then the recent IMNSHO clunky DATEDIFF(arg,arg,'scale')


Maguin, Eugene wrote
> Gotta read up on date/time functions in the CSR.
>
> *  assume mm/dd/yyyy date structure.
> If (DDate eq date.mdy(12,5,2006) temp=1.
>
> Gene maguin
>
> From: SPSSX(r) Discussion [mailto:

> SPSSX-L@.UGA

> ] On Behalf Of Robert Lundqvist
> Sent: Monday, June 02, 2014 10:09 AM
> To:

> SPSSX-L@.UGA

> Subject: Condition with time variable?
>
> I can't find out how to deal with time variables in transformations.
> The code I have started out with is
>
> IF  DDate= 2006/12/05 temp=1.
>
> But it doesn't work. The same goes for
>
> IF  (DDate=XDATE.DATE(2006/12/05)) temp=1.
>
> Nothing happens, temp is simply filled with missing values. This
> should not be that difficult, should it?
>
> Robert





-----
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?"
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Condition-with-time-variable-tp5726307p5726310.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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
Robert Lundqvist