Hi All,
I am hoping to get some advice about a possible macro or looping expression that may save me some time here.
I have 50 columns of data across 90,000 rows that stipulate product departments that each individual viewed during a specific web visit. Each column could take one of 72 numeric values (e.g. 10, 57, 231 etc.) or be missing because the individual did not view any items.
What I am trying to achieve is to add extra columns that count how many times each department is viewed (i.e. how many times each value occurs across each row).
A simple (but lengthy) way I have found is to use a count function for each department value, e.g. the syntax below counts how many times the value 10 occurs across the 50 rows (labelled department 1 to 50 to stipulate the product department of item 1 to 50):
COUNT CountDept10=department1 department2 department3 department4 department5 department6 department7
department8 department9 department10 department11 department12 department13 department14
department15 department16 department17 department18 department19 department20 department21
department22 department23 department24 department25 department26 department27 department28
department29 department30 department31 department32 department33 department34 department35
department36 department37 department38 department39 department40 department41 department42
department43 department44 department45 department46 department47 department48 department49
department50(10).
EXECUTE.
Rather than having to copy this syntax 72 times and replace the 10 with each unique department value, I am hoping there is a way to give SPSS a list of the values and tell it to repeat the syntax replacing the 10 with each value in turn.
Any thoughts/ advice would be greatly appreciated!
Jason
I am hoping to get some advice about a possible macro or looping expression that may save me some time here.
I have 50 columns of data across 90,000 rows that stipulate product departments that each individual viewed during a specific web visit. Each column could take one of 72 numeric values (e.g. 10, 57, 231 etc.) or be missing because the individual did not view any items.
What I am trying to achieve is to add extra columns that count how many times each department is viewed (i.e. how many times each value occurs across each row).
A simple (but lengthy) way I have found is to use a count function for each department value, e.g. the syntax below counts how many times the value 10 occurs across the 50 rows (labelled department 1 to 50 to stipulate the product department of item 1 to 50):
COUNT CountDept10=department1 department2 department3 department4 department5 department6 department7
department8 department9 department10 department11 department12 department13 department14
department15 department16 department17 department18 department19 department20 department21
department22 department23 department24 department25 department26 department27 department28
department29 department30 department31 department32 department33 department34 department35
department36 department37 department38 department39 department40 department41 department42
department43 department44 department45 department46 department47 department48 department49
department50(10).
EXECUTE.
Rather than having to copy this syntax 72 times and replace the 10 with each unique department value, I am hoping there is a way to give SPSS a list of the values and tell it to repeat the syntax replacing the 10 with each value in turn.
Any thoughts/ advice would be greatly appreciated!
Jason