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 (November 2011)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 3 Nov 2011 15:48:58 -0000
Reply-To:     joan casellas <joan.casellas@eu-survey.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         joan casellas <joan.casellas@eu-survey.com>
Subject:      Re: Loop
Comments: To: David Marso <david.marso@gmail.com>
In-Reply-To:  <1320329858400-4961182.post@n5.nabble.com>
Content-Type: text/plain; charset="us-ascii"

Hi David,

I maybe should clarify the problem. Basically, I have two questions: q23 (with 10 options/statements) and q24 (showing options/statements selected in q23) where people gave a score (1 to 5).

Before q24 there is a filter and it works like this: If you select 2 options in q23 you will see these two options in q24 If you select more than 2 options in q23 you will see randomly two of these selected options in q24 If you select just one option in q23, you will see in q24 this selected option plus another randomly option from q24

I want to reclassify people that have selected just one option in q23 and answered the option shown randomly in q24.

*Create a new variable: Compute newvariable=$sysmis. *Select people that selected just one option and assign response from q24: If (q23_1=1) newvariable=q24r. *Treat 0 as missing If (sys(q24r) newvariable=$sysmis. *Labeling val lab newvariable 1 'Very poor' 2 'Poor' 3 'Neither' 4 'Good' 5 'Very good'..

I hope now it makes more sense.

Thanks in advance

-----Original Message----- From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of David Marso Sent: 03 November 2011 14:18 To: SPSSX-L@LISTSERV.UGA.EDU Subject: Re: Loop

Probably the simplest approach would be to use DO REPEAT: You could use VECTORS and LOOP but that's like using a sledgehammer to kill a fly on the wall. -- Assuming vars are in order (to save me from typing, list them out if they are not).

DO REPEAT CheckForOne=q23_1 TO q23_10 / SourceVar=q24r1 TO q24r10 / ResultVar=q24rr1 TO q24rr10 .

* Not needed /Some (Art, Myself ... would be appalled if this showed up in production code, * User defined missing values exist for a reason)* Besides, variable will DEFAULT to Sysmis *. *compute ResultVar=$sysmis.

if (CheckForOne EQ 1) ResultVar=SourceVar.

* Unnecessary (Redundant to the above IF since ResultVar is SYSMIS by DEFAULT). *if (SYSMIS(SourceVar))ResultVar=$sysmis. *Assumes -999 is *NOT* a valid possible value for SourceVar/ResultVar *. * Be careful if there ARE already user defined missing values for SourceVars *. IF MISSING(ResultVar) ResultVar=-999. VALUE LABELS ResultVar 1 'No benefit at all' 2 'Not much benefit' 3 'Some benefit' 4 'Great benefit' -999 'Missing Check variable or source variable'. END REPEAT. ---

joan casellas wrote: > > Dear list, > > > > I have the following syntax and I would like to do the same 10 times. I > have > to create a loop and change the value highlighted it yellow. Any > suggestions? > > > > > > compute q24rr1=$sysmis. > > if (q23_1=1) q24rr1=q24r1. > > if (sys(q24r1))q24rr1=$sysmis. > > val lab q24rr 1 'No benefit at all' 2 'Not much benefit' 3 'Some benefit' > 4 > 'Great benefit'. > > fre q24r1 q24rr1. > > > > Any help would be really appreciated. Thanks in advance. > > > > Joan >

-- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Loop-tp4960941p4961182.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

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


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