Re: creating half hourly interval numeric variable from a time variable
Posted by
Art Kendall on
Feb 08, 2013; 2:25pm
URL: http://spssx-discussion.165.s1.nabble.com/creating-half-hourly-interval-numeric-variable-from-a-time-variable-tp5717982p5717987.html
It sound like you have
a LOOP or something before the execute.
See if this example syntax
does what you want.
I do not know what you meant by
"etc". Can you cobble together an example
syntax set of data that shows what you
want?
data list list /starttime
(time8) want (f2).
begin data
00:12:01 1
11:03:01 1
00:32:30 2
02:29:58 1
05:30:01 2
18:06:33 1
14:45:33 2
02:23:01 1
end data.
COMPUTE minperiod=XDATE.MINUTE(StartTime).
compute period=-1.
IF (minperiod lt 30) period=1.
IF (minperiod ge 30) period=2.
formats period (f2).
missing values period(-1).
list varaibles = starttime want period.
Art Kendall
Social Research Consultants
On 2/8/2013 7:56 AM, Paul McGeoghan wrote:
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
=====================
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
Art Kendall
Social Research Consultants