LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (September 2005)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 29 Sep 2005 11:26:21 -0400
Reply-To:     Richard Ristow <wrristow@mindspring.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Richard Ristow <wrristow@mindspring.com>
Subject:      Re: Finding information on +
Comments: To: Martin Sherman <MSherman@loyola.edu>
In-Reply-To:  <s33bb94e.096@GWMAIL01.LOYOLA.EDU>
Content-Type: text/plain; charset="us-ascii"; format=flowed

At 09:52 AM 9/29/2005, Martin Sherman wrote:

>My help command on SPSS 13.0 is not functioning

So, you're helpless? <Sorry. I'm flaky this morning>

>I am trying to get a handle on the use of the + sign in a do if >loop. Is it >simply allowing one to use a do if within a do if? [For example,] >do if nmiss(pcl_b, pcl_c, pcl_d) eq 0. >+ Do if (pcl_b ge 1 and pcl_c ge 3 and pcl_d ge 2). >+ compute pcl_dsm3=1. >+ else if (pcl_b lt 1 or pcl_c lt 3 or pcl_d lt 2). >+ compute pcl_dsm3=0. >+ end if. >Else. >Compute pcl_dsm3 eq 9. >End if.

The '+' sign is for the appearance of the code, only, though the appearance is important.

In interactive syntax rules, a statement has to start at the left margin. To allow "indenting" for readability, SPSS counts a '+', '-' or '.' in the left margin as the beginning of a statement; the keyword can then follow anywhere on the line.

(Raynald Levesque pointed out a while ago that '-' and '.' can be safer than '+', which sometimes can be confused with the '+' that signifies a string is continued on the next line. You aren't using string literals, so that's OK.)

You can always use a DO IF construct within another one, though you have to be sure your END IFs are in the right place. The code you wrote,

do if nmiss(pcl_b, pcl_c, pcl_d) eq 0. + Do if (pcl_b ge 1 and pcl_c ge 3 and pcl_d ge 2). + compute pcl_dsm3=1. + else if (pcl_b lt 1 or pcl_c lt 3 or pcl_d lt 2). + compute pcl_dsm3=0. + end if. Else. Compute pcl_dsm3 eq 9. End if.

is equivalent to

do if nmiss(pcl_b, pcl_c, pcl_d) eq 0. Do if (pcl_b ge 1 and pcl_c ge 3 and pcl_d ge 2). compute pcl_dsm3=1. else if (pcl_b lt 1 or pcl_c lt 3 or pcl_d lt 2). compute pcl_dsm3=0. end if. Else. Compute pcl_dsm3 eq 9. End if.

but that's nowhere near as readable. On the other hand, you can (and I would) go yet farther with the indenting:

do if nmiss(pcl_b, pcl_c, pcl_d) eq 0. + Do if (pcl_b ge 1 and pcl_c ge 3 and pcl_d ge 2). + compute pcl_dsm3=1. + else if (pcl_b lt 1 or pcl_c lt 3 or pcl_d lt 2). + compute pcl_dsm3=0. + end if. Else. + Compute pcl_dsm3 eq 9. End if.

That is, two spaces of "indenting" for each construct the statement is within.


Back to: Top of message | Previous page | Main SPSSX-L page