PSPP / SPSS syntax like

How can I use the syntax to fill specific lines with specific variables. Suppose I want to fill lines 1-10 in my "location" variable with integer 1. Lines 10-70 with 2 and so on. No programming. I just want to fill specific lines of a variable with specific values ​​instead of having to do it manually. I've tried using vectors and loops, but it only works between columns.

+3


source to share


2 answers


The basic syntax will look like this:



do if $casenum le 10.
   compute myvar = 1.
else if $casenum le 70.
   compute myvar = 2.
else. 
   compute myvar = 3.
end if.
exe.

      

+3


source


Assuming your dataset is already populated, $ casenum matches rows by row number.



Combine with IF to set values. You can cut this down a bit using RANGE .

+2


source







All Articles