Sometimes you will want to generate values for a column in a new dataset.
There is no easy builtin way to do this in SPSS. Here are two methods for
generating the values from 1 to n in a new column.
Using Excel
One method to enter a range, say 1 to 100, into an empty dataset is
to use MS Excel:
Enter the values 1 and 2 into the first two rows of an empty column.
Select the values 1 and 2.
Move the cursor until a solid black cursor is obtained.
Drag the cursor down to row 100. This will drag out the values
1 to 100 in the column.
Right click on the column header and select Copy.
Paste the column into the top cell of a column in the SPSS Dataset
Editor.
Using an SPSS Script
Another method to enter a range into an empty dataset
is to execute an SPSS syntax source code:
Select File >> New >> Syntax.
Enter this SPSS Script:
input program.
loop #i = 1 to 100.
compute i = #i.
end case.
end loop.
end file.
end input program.
execute.
Select Run >> All in the Syntax Editor. A variable i with
values 1 to 100 should now exist in the new dataset that is created.
Don't forget the . at the end of each line.
Only use this technique for new databases, not ones with existing data.