Re: How to calculate (sum) from multiple variable thru loop, if variable are not in sequential order

Posted by Bruce Weaver on
URL: http://spssx-discussion.165.s1.nabble.com/How-to-calculate-sum-from-multiple-variable-thru-loop-if-variable-are-not-in-sequential-order-tp5741009p5741019.html

Good comments, PR.  You are absolutely right in noting that some tasks are much easier with a LONG file than a WIDE file.  

PRogman wrote
I am looking over your data set. You have 556 cases and 7735 variables.
The variable structure seems to have 5 initial unique names, then a block of variables starting with Q5_10_# thru Q67_T_#, where # changes from 2 to 246 and then from 1000 to 1068.
Maybe you are working in the wrong (wide) format. Some tasks are more difficult in the wrong database format. Do you have data in long format? If so, FILTER and AGGREGATE may solve your problems.
BTW, the variables SAT_NUM_AVA_# are not inte file.
 
Apparnet variable structure in Test.sav:
Initial 5 variables
  SRL        (not unique values, 162 duplicates)
  Q6I_T_1  
  Q6II_T_1
  Q7_T_1  
  Q67_T_1
then repeat # = [2...246, 1001...1068]
    Q5_10_#    Q5_20_#
    Q6I_10_#   Q6I_20_#
    Q6II_10_#  Q6II_20_#
    Q7_10_#    Q7_20_#
    Q8A_#       Q8B_#
    Q9MN_1_#  Q9YR_1_#
    Q9MN_2_#  Q9YR_2_#
    Q9MN_3_#  Q9YR_3_#
    NUM_DIS_#
    NUM_OOS_#
    EXPIR_#
    WT_DIS_#
    WT_OOS_#
    Q5_T_#    
    Q6I_T_#   Q6II_T_#
    Q7_T_#    Q67_T_#

/PR
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).