Login  Register

creating half hourly interval numeric variable from a time variable

Posted by Paul Mcgeoghan on Feb 08, 2013; 12:56pm
URL: http://spssx-discussion.165.s1.nabble.com/creating-half-hourly-interval-numeric-variable-from-a-time-variable-tp5717982.html

Hi,

I have a time variable StartTime hh:mm:ss.
I need to work out a new numeric variable so that between 00:00 and 00:29,
it will be 1; between 00:30 and 00:59, it will be 2; etc.
So I have syntax such as:

COMPUTE hourperiod=XDATE.HOUR(StartTime).
EXECUTE.
COMPUTE minperiod=XDATE.MINUTE(StartTime).
EXECUTE.
IF  (hourperiod=0 & minperiod<30) period=1.
EXECUTE.
IF  (hourperiod=0 & minperiod>=30) period=2.
EXECUTE.

It doesn't seem to like this syntax though.
I get errors:
IF  (hourperiod=0 & minperiod<30) period=1.
EXECUTE.
>Warning # 142.  Command name: EXECUTE
>LOOP has no effect on this command.

>Error # 4095.  Command name: EXECUTE
>The transformations program contains an unclosed LOOP, DO IF, or complex
file
>structure.  Use the level-of-control shown to the left of the SPSS
Statistics
>commands to determine the range of LOOPs and DO IFs.
>Execution of this command stops.

Is this the best way to achieve this?

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