Reputation: 3640
In my SPSS Syntax Script I compute a bunch of formulas for each cases.
Let' say this is my data:
id value
1 34
2 12
3 94
I now compute a new variable where I need the number of cases in the file (number of ids) So
COMPUTE newvar = value/ NUMBER OF CASES
in this example NUMBER OF CASES would be 3.
Is there a command for this? thx
Upvotes: 2
Views: 352
Reputation: 5089
You can use the AGGREGATE
command without a break variable to return the number of cases in the dataset. Example below:
DATA LIST FREE / ID Value.
BEGIN DATA
1 34
2 12
3 94
END DATA.
AGGREGATE OUTFILE=* MODE=ADDVARIABLES
/BREAK
/NumberOfCases=N.
COMPUTE NewVar = Value/NumberOfCases.
Upvotes: 2