Size: 1477
Comment:
|
← Revision 3 as of 2023-06-11 21:13:39 ⇥
Size: 1849
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 30: | Line 30: |
The '''`/INDEX`''' subcommand creates an index variable marking a created row's sequence within its group. | The '''`/INDEX`''' subcommand creates an index variable marking a created row's sequence within its group. This index variable will have an `F8.0` format. |
Line 38: | Line 38: |
To create an index variable that instead lists the ''name'' of the source variable variable, try: | To create an index variable that instead stores the string ''name'' of the source variable variable, try: |
Line 51: | Line 51: |
---- == Data Model == The `VARSTOCASES` command recognizes [[SPSS/SplitFile|SPLIT FILE]] and [[SPSS/Weight|WEIGHT]] statuses and preserves them, unless the relevant variables are used on a `/DROP` or `/MAKE` subcommand. The `VARSTOCASES` command does ''not'' recognize [[SPSS/Filter|FILTER]] status. |
SPSS VarsToCases
The VARSTOCASES command translates a wide dataset into long format. See also CASESTOVARS.
Contents
Usage
varstocases /make Sales from Sales.1 to Sales.4.
For each variable listed after FROM, a new row of data is created with that variable's value set instead into the /MAKE variable. All other variables are duplicated for each created row of data.
Id
The /ID subcommand creates a numeric variable storing the $casenum on the original, wide dataset. If the dataset already has an ID variable, it will automatically be duplicated to each created row of data, and the /ID subcommand won't offer any significant advantage over this.
Index
The /INDEX subcommand creates an index variable marking a created row's sequence within its group. This index variable will have an F8.0 format.
varstocases /make Sales from Sales.1 to Sales.4 /index=fiscalquarter.
To create an index variable that instead stores the string name of the source variable variable, try:
varstocases /make Sales from Sales.1 to Sales.4 /index=fiscalquarter (Sales).
Null
By default, SPSS will not create a row for missing values found on the /MAKE subcommand's FROM list. Add the /NULL=DROP subcommand to explicitly allow this behavior, or add the /NULL=KEEP subcommand to disable it.
Data Model
The VARSTOCASES command recognizes SPLIT FILE and WEIGHT statuses and preserves them, unless the relevant variables are used on a /DROP or /MAKE subcommand.
The VARSTOCASES command does not recognize FILTER status.