3

How can I use syntax to fill specific rows with specific variables. Lets say I want to fill row 1 to 10 in my "location" variable with the integer 1. Rows 10-70 with 2 and so on. There is no programming I just want to fill specific rows of a variable with specific values instead of doing it manually. I tried using vectors and loops but it only works across columns.

Jignesh Sutar
  • 2,909
  • 10
  • 13
Ned321
  • 33
  • 2

2 Answers2

3

The basic syntax would be along the lines of:

do if $casenum le 10.
   compute myvar = 1.
else if $casenum le 70.
   compute myvar = 2.
else. 
   compute myvar = 3.
end if.
exe.
Ritchie Sacramento
  • 29,890
  • 4
  • 48
  • 56
2

Presuming your dataset is already populated, $casenum addresses rows by their row numbers.

Combine with IF for setting values. You may be able to shorten this a bit by using RANGE.

RubenGeert
  • 2,902
  • 6
  • 32
  • 50