Duplicate cases n times where n is variable
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | SPSS AnswerNet: Result Solution ID: 100000480 Title: How to duplicate cases n times based on a value of a variable? Description: Q. I need to duplicate every case n times and n is the value for a special variable (v1) which it varies from case to case. I tried loop and xsave commands but loop does not take values from variable names. What should I do? A. Here is syntax that will allow you to do this. In the LOOP command, MAX is the maximum value of the V1 variable (you may use a DESCRIPTIVES command to learn the maximum value. Simply plug this number in the LOOP command): LOOP id=1 to MAX. XSAVE outfile='test'/keep all. END LOOP. EXECUTE. GET file 'test'. SELECT IF (id LE v1). EXECUTE |
Related pages
...