|
Hello List,
I am attempting to delete the values in a consecutive series of variables (several thousand of them) using the following syntax: do if comp ne 1. do repeat clear = Q1 to D7.
compute clear = $sysmis. end repeat. end if. exe. I am rather new with SPSS syntax so I'm guessing there's something very fundamental at work here that's causing the problem. The above code runs but it does not do as I need. Values are not cleared from the variables from Q1 to D7. What am I missing here?
|
|
What is your goal? From: SPSSX(r) Discussion
[mailto:[hidden email]] On Behalf Of Jim Arnold Hello List, I am attempting to delete the values in a consecutive series
of variables (several thousand of them) using the following syntax: do if comp ne 1. do repeat clear = Q1 to D7. compute clear = $sysmis. end repeat. end if. exe. I am rather new with SPSS syntax so I'm guessing there's
something very fundamental at work here that's causing the problem. The
above code runs but it does not do as I need. Values are not cleared from
the variables from Q1 to D7. What am I missing here? |
|
To remove any and all values stored within the variables. Blank-em out.
On Sun, May 3, 2009 at 7:47 PM, ViAnn Beadle <[hidden email]> wrote:
|
|
In reply to this post by Jim Arnold-3
It is poor programming to have $sysmis on the right hand side of a command.
One of the strengths of SPSS is the distinction between user missing and system missing. If you preserve this distinction it can be a great help to you as you go through the drafts of your application. System missing values should only appear when the program is unable to do what you tell it and the missing value is assigned by the system. Examples are when the data cannot be read as you instruct in the format Examples are: 'd/k' is not a valid number. The program cannot divide by zero, nor can it find the sum of a valid number and a missing number., etc. When the user tells the program to treat a value as missing that means the value is "user missing". These are given value labels that are outside the valid range of responses. value labels item01 to item 10 1 'strongly disagree' 2 'disagree' 3 'neither' 4 'agree' 5 'strongly agree' -1 'interviewer forgot to ask' -2 'refused to answer' -3 'respondent said not applicable' -4 'form mangled in mail unreadable' -5 'legitimate skip'. missing values item01 to item10 (lo thru -1). Open a new instance of SPSS. Copy the syntax below to a syntax file. Click <run>. Click <all>. Is this what you are looking for? data list list /id (f3) comp (f1) q1 (f4) something(f4) d7 (f4). begin data 1 1 1 1 1 2 1 2 2 2 3 2 1 1 1 4 2 2 2 2 end data. do if comp ne 1. do repeat clear = Q1 to D7. compute clear = -999. end repeat. end if. missing values q1 to d7(lo thru -1). add value labels q1 to d7 -999 'whatever reason'. list. Art Kendall Social Research Consultants Jim Arnold wrote: > Hello List, > > I am attempting to delete the values in a consecutive series of > variables (several thousand of them) using the following syntax: > > do if comp ne 1. > do repeat clear = Q1 to D7. > compute clear = $sysmis. > end repeat. > end if. > exe. > > I am rather new with SPSS syntax so I'm guessing there's something > very fundamental at work here that's causing the problem. The above > code runs but it does not do as I need. Values are not cleared from > the variables from Q1 to D7. What am I missing here? ===================== 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 |
|
In reply to this post by Jim Arnold-3
At 05:24 PM 5/3/2009, Jim Arnold wrote:
I am attempting to delete the values in a consecutive series of variables (several thousand of them) using the following syntax: I think the simplest way is with RECODE; see the following example. But your syntax should work. It works for me (see test, below). Do you get any error messages? Are Q1 to D7 contiguous in your file? [TestData] CaseID Comp Q1 Q2 Q3 D5 D6 D7 001 0 5 4 3 2 1 0 002 1 19 20 21 22 23 24 003 0 1 4 9 16 25 36 004 1 2 3 5 7 11 13 Number of cases read: 4 Number of cases listed: 4 DATASET ACTIVATE TestData. DATASET COPY Recode. DATASET ACTIVATE Recode. do if comp ne 1. . RECODE Q1 to D7 (ELSE = SYSMIS). end if. LIST. |-----------------------------|---------------------------| |Output Created |04-MAY-2009 12:03:43 | |-----------------------------|---------------------------| [Recode] CaseID Comp Q1 Q2 Q3 D5 D6 D7 001 0 . . . . . . 002 1 19 20 21 22 23 24 003 0 . . . . . . 004 1 2 3 5 7 11 13 Number of cases read: 4 Number of cases listed: 4 Test of DO REPEAT syntax: DATASET ACTIVATE TestData. DATASET COPY Do_Repeat. DATASET ACTIVATE Do_Repeat. do if comp ne 1. . do repeat clear = Q1 to D7. . compute clear = $sysmis. . end repeat. end if. LIST. List |-----------------------------|---------------------------| |Output Created |04-MAY-2009 12:03:44 | |-----------------------------|---------------------------| [Do_Repeat] CaseID Comp Q1 Q2 Q3 D5 D6 D7 001 0 . . . . . . 002 1 19 20 21 22 23 24 003 0 . . . . . . 004 1 2 3 5 7 11 13 Number of cases read: 4 Number of cases listed: 4 ============================= APPENDIX: Test data, and code ============================= DATA LIST LIST/ CaseID Comp Q1 Q2 Q3 D5 D6 D7. BEGIN DATA 001 0 5 4 3 2 1 0 002 1 19 20 21 22 23 24 003 0 1 4 9 16 25 36 49 004 1 2 3 5 7 11 13 17 END DATA. FORMATS CASEID (N3) Comp (F2) Q1 TO D7 (F3). DATASET NAME TestData. LIST. DATASET ACTIVATE TestData. DATASET COPY Recode. DATASET ACTIVATE Recode. do if comp ne 1. . RECODE Q1 to D7 (ELSE = SYSMIS). end if. LIST. DATASET ACTIVATE TestData. DATASET COPY Do_Repeat. DATASET ACTIVATE Do_Repeat. do if comp ne 1. . do repeat clear = Q1 to D7. . compute clear = $sysmis. . end repeat. end if. LIST. ===================== 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 |
| Free forum by Nabble | Edit this page |
