|
I have dataset with 50 variables and n>2000 with 4-point Likert scale values coded 1 to 4. I want to delete the cases with same values that exceed or equal to 90% of the number of variables. For example, case number 100 is deleted from the database because 45 out of 50 variables have values of 4; case number 200 is deleted because all values in the 50 variables are 1.
I appreciate if somebody could provide the syntax. Thank you. J. Amora Johnny T. Amora Statistician, Center for Learning and Performance Assessment De La Salle-College of Saint Benilde Manila, Philippines ===================== 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 |
|
At 04:01 AM 5/30/2008, Johnny Amora wrote:
>I have a dataset with 50 variables with 4-point Likert scales coded >1 to 4. I want to delete the cases [where the same value occurs in] >90% of the variables. You can use LOOP logic to count the number of occurrences of each of the four values, and reject if any of the four resulting counts are larger than 90% of the number of valid values. Here's tested syntax, with 10 Likert-scale variables: |-----------------------------|---------------------------| |Output Created |01-JUN-2008 20:52:39 | |-----------------------------|---------------------------| CaseID LK1 LK2 LK3 LK4 LK5 LK6 LK7 LK8 LK9 LK10 001 1 1 3 2 3 1 3 1 4 3 002 2 4 2 2 3 3 3 4 2 2 003 1 1 1 1 4 4 4 2 3 3 004 4 2 2 3 3 4 4 4 1 4 005 4 1 4 2 3 4 4 4 4 3 006 3 3 4 1 1 3 3 1 1 3 007 1 1 1 1 1 1 1 2 3 4 008 1 2 2 2 2 2 2 2 3 4 009 1 2 3 3 3 3 3 3 3 4 010 1 2 3 4 4 4 4 4 4 4 Number of cases read: 10 Number of cases listed: 10 NUMERIC NV NV.1 TO NV.4 (F3). VAR LABEL NV 'Number of valid Likert scale values'. COMPUTE NV=NVALID(LK1 TO LK10). VAR LABEL NV.1 'Number of scales with value 1' NV.2 'Number of scales with value 2' NV.3 'Number of scales with value 3' NV.4 'Number of scales with value 4'. RECODE NV.1 TO NV.4 (ELSE=0) /* Initialize counts to zero */. VECTOR LIKERT = LK1 TO LK10. LOOP #SCALE = 1 TO 10. . DO REPEAT VALUE = 1 TO 4 /COUNTER = NV.1 TO NV.4. . IF LIKERT(#SCALE) EQ VALUE COUNTER = COUNTER + 1. . END REPEAT. END LOOP. LIST. List |-----------------------------|---------------------------| |Output Created |01-JUN-2008 20:52:40 | |-----------------------------|---------------------------| CaseID LK1 LK2 LK3 LK4 LK5 LK6 LK7 LK8 LK9 LK10 NV NV.1 NV.2 NV.3 NV.4 001 1 1 3 2 3 1 3 1 4 3 10 4 1 4 1 002 2 4 2 2 3 3 3 4 2 2 10 0 5 3 2 003 1 1 1 1 4 4 4 2 3 3 10 4 1 2 3 004 4 2 2 3 3 4 4 4 1 4 10 1 2 2 5 005 4 1 4 2 3 4 4 4 4 3 10 1 1 2 6 006 3 3 4 1 1 3 3 1 1 3 10 4 0 5 1 007 1 1 1 1 1 1 1 2 3 4 10 7 1 1 1 008 1 2 2 2 2 2 2 2 3 4 10 1 7 1 1 009 1 2 3 3 3 3 3 3 3 4 10 1 1 7 1 010 1 2 3 4 4 4 4 4 4 4 10 1 1 1 7 Number of cases read: 10 Number of cases listed: 10 ============================= APPENDIX: Test data, and code ============================= * ................................................................. . * ................. Test data ..................... . SET RNG = MT /* 'Mersenne twister' random number generator */ . SET MTINDEX = 7778 /* Providence, RI telephone book */ . INPUT PROGRAM. . NUMERIC CaseID (N3). . LEAVE CaseID. . NUMERIC LK1 TO LK10 (F2). . VECTOR LIKERT = LK1 TO LK10. . LOOP CaseID = 1 TO 06. . LOOP #SCALE = 1 TO 10. . COMPUTE LIKERT(#SCALE) = TRUNC(RV.UNIFORM(1,5)). . END LOOP. . END CASE. . END LOOP. . LOOP Caseid = 07 TO 10. . COMPUTE LK1 = 1. . COMPUTE LK2 = 2. . COMPUTE LK3 = 3. . COMPUTE LK4 = 4. . COMPUTE LK10 = 4. . COMPUTE LK9 = 3. . COMPUTE LK8 = 2. . COMPUTE LK7 = 1. . COMPUTE #VALUE = CaseID - 6. . LOOP #SCALE = #VALUE TO #VALUE + 6. . COMPUTE LIKERT(#SCALE) = #VALUE. . END LOOP. . END CASE. . END LOOP. END FILE. END INPUT PROGRAM. * ................. Post after this point ..................... . * ................................................................. . LIST. NUMERIC NV NV.1 TO NV.4 (F3). VAR LABEL NV 'Number of valid Likert scale values'. COMPUTE NV=NVALID(LK1 TO LK10). VAR LABEL NV.1 'Number of scales with value 1' NV.2 'Number of scales with value 2' NV.3 'Number of scales with value 3' NV.4 'Number of scales with value 4'. RECODE NV.1 TO NV.4 (ELSE=0) /* Initialize counts to zero */. VECTOR LIKERT = LK1 TO LK10. LOOP #SCALE = 1 TO 10. . DO REPEAT VALUE = 1 TO 4 /COUNTER = NV.1 TO NV.4. . IF LIKERT(#SCALE) EQ VALUE COUNTER = COUNTER + 1. . END REPEAT. END LOOP. 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 |
