Date: Fri, 5 Aug 2011 08:23:42 -0700
Reply-To: Bruce Weaver <bruce.weaver@hotmail.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Bruce Weaver <bruce.weaver@hotmail.com>
Subject: Re: Unclosed loop
In-Reply-To: <1312555730538-4669757.post@n5.nabble.com>
Content-Type: text/plain; charset=UTF-8
I received this from the OP via e-mail:
/Thanks,
But still getting the unclosed loop error. I need to get to our SPSS guru
once he’s back from vacation.
/
It works for me--see below. This makes me wonder if your unclosed loop is
being caused by something earlier in the syntax file.
data list free / reldate (date11).
begin data
15-Jan-1999 31-Mar-1999 1-Apr-1999
15-Jan-2000 31-Mar-2000 1-Apr-2000
15-Jan-2001 31-Mar-2001 1-Apr-2001
15-Jan-2002 31-Mar-2002 1-Apr-2002
15-Jan-2003 31-Mar-2003 1-Apr-2003
15-Jan-2004 31-Mar-2004 1-Apr-2004
15-Jan-2005 31-Mar-2005 1-Apr-2005
15-Jan-2006 31-Mar-2006 1-Apr-2006
15-Jan-2007 31-Mar-2007 1-Apr-2007
end data.
do repeat i = 1 to 8 / y1 = 1999 to 2006 / y2 = 2000 to 2007.
- if RANGE(reldate,date.mdy(4,1,y1),date.mdy(3,31,y2)) fy = i.
end repeat.
execute.
list.
Output:
reldate fy
15-JAN-1999 .
31-MAR-1999 .
01-APR-1999 1
15-JAN-2000 1
31-MAR-2000 1
01-APR-2000 2
15-JAN-2001 2
31-MAR-2001 2
01-APR-2001 3
15-JAN-2002 3
31-MAR-2002 3
01-APR-2002 4
15-JAN-2003 4
31-MAR-2003 4
01-APR-2003 5
15-JAN-2004 5
31-MAR-2004 5
01-APR-2004 6
15-JAN-2005 6
31-MAR-2005 6
01-APR-2005 7
15-JAN-2006 7
31-MAR-2006 7
01-APR-2006 8
15-JAN-2007 8
31-MAR-2007 8
01-APR-2007 .
Number of cases read: 27 Number of cases listed: 27
Bruce Weaver wrote:
>
> I don't see anything wrong. But DO-IF with that many ELSE lines is always
> a bit hard to read. I think something like the following (untested) might
> work. If it does, it's a lot easier to read.
>
> do repeat i = 1 to 8 / y1 = 1999 to 2006 / y2 = 2000 to 2007.
> - if RANGE(reldate,date.mdy(4,1,y1),date.mdy(3,31,y2)) fy = i.
> end repeat.
> execute.
>
> HTH.
>
>
>
> shorne wrote:
>>
>> Using the following code in SPSS 11 and get the following error:
>>
>>>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
>>>commands to determine the range of LOOPs and DO IFs.
>>>This command not executed.
>>
>> Am I missing something at the bottom?
>>
>> Do if reldate >= date.mdy(4,1,1999) and reldate <= date.mdy(3,31,2000).
>> comp fy=1.
>> ELSE if reldate >= date.mdy(4,1,2000) and reldate <= date.mdy(3,31,2001).
>> comp fy=2.
>> ELSE if reldate >= date.mdy(4,1,2001) and reldate <= date.mdy(3,31,2002).
>> comp fy=3.
>> ELSE if reldate >= date.mdy(4,1,2002) and reldate <= date.mdy(3,31,2003).
>> comp fy=4.
>> ELSE if reldate >= date.mdy(4,1,2003) and reldate <= date.mdy(3,31,2004).
>> comp fy=5.
>> ELSE if reldate >= date.mdy(4,1,2004) and reldate <= date.mdy(3,31,2005).
>> comp fy=6.
>> ELSE if reldate >= date.mdy(4,1,2005) and reldate <= date.mdy(3,31,2006).
>> comp fy=7.
>> ELSE if reldate >= date.mdy(4,1,2006) and reldate <= date.mdy(3,31,2007).
>> comp fy=8.
>> END IF.
>> EXECUTE.
>>
>
-----
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/
"When all else fails, RTFM."
NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Unclosed-loop-tp4669655p4669862.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.
=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (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
|