pspp-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DO IF Block appears to execute regardless


From: Ben Pfaff
Subject: Re: DO IF Block appears to execute regardless
Date: Mon, 3 Feb 2014 07:58:56 -0800
User-agent: Mutt/1.5.21 (2010-09-15)

That makes sense.  Thanks for the follow-up, and let us know if you
suspect that there is anything wrong with PSPP.

On Mon, Feb 03, 2014 at 09:23:35AM +1100, Stuart McKenzie wrote:
> Hi Ben
> 
> Thanks for the follow up.  The error was a 'kind of' red herring.  I have
> a script that needs to run across 2 different data sources  and the
> variable list doesn't quite match between them. I was wanting to use the
> DO IF block to execute a specific set of actions against only one of the
> data sources, as the block referred to a variable that was only in one of
> the data sources.  So I suspect that it is the compilation and validation
> of the script that was throwing the error when it encounters a reference
> to a variable that isn't in the script. I had erroneously thought that the
> error was being thrown during execution, not validation.
> 
> Regards
> Stuart
> 
> 
> -----Original Message-----
> From: Ben Pfaff [mailto:address@hidden
> Sent: Monday, 3 February 2014 5:04 AM
> To: Stuart McKenzie
> Cc: address@hidden
> Subject: Re: DO IF Block appears to execute regardless
> 
> On Thu, Jan 16, 2014 at 02:49:33PM +1100, Stuart McKenzie wrote:
> > I have a block of code
> >
> > COMPUTE PulseCheck = INDEX(UPCASE(@JobName),"PULSE") > 0.
> >
> > DO IF (PulseCheck < 1).
> >     Recode CONT (Convert) into CONT1.
> >     *do other stuff
> > END IF.
> >
> > If I include the line
> > LIST PulseCheck
> > I see that PulseCheck is being calculated correctly so that line
> > appears to be correct, however, the DO IF block of code currently
> > executes regardless of the value of PulseCheck. This script is used to
> > run across 2 data files, one of which has the CONT variable and the
> > other doesn't, so I need to skip over this block when the CONT
> > variable does not exist.  Am I missing something stupidly obvious
> > here? The less preferred solution is to use 2 scripts, but that has
> > other implications which I would prefer not to have to deal with.
> 
> I finally took a look at this.  Sorry about the long delay.
> 
> I can't reproduce the problem here.  When I run the following, for
> example:
> 
>     DATA LIST LIST NOTABLE/input.
>     BEGIN DATA.
>     1
>     2
>     3
>     4
>     5
>     END DATA.
>     DO IF input < 3.
>         RECODE input (1=2)(ELSE=COPY) INTO output.
>     END IF.
>     LIST.
> 
> I see the expected output:
> 
>     Data List
>        input   output
>     -----------------
>         1.00     2.00
>         2.00     2.00
>         3.00        .
>         4.00        .
>         5.00        .
> 
> which shows that indeed the RECODE isn't doing anything for input values
> less than 3.
> 
> If you can provide a complete example of syntax that doesn't behave as you
> expect, I'll figure out the problem.
> 
> Thanks,
> 
> Ben.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]