1

I have over 338 columns with different drug name in each column. what I want to do is to loop through all the columns using the code. This code is for one specific drug. The problem is I have 338 different drug names. The code is:

NPTESTS 
/INDEPENDENT TEST (PLIN3 CYFIP2 IL2RA HSD3B1 IL2RB PYROXD1 ZBED4 MCTP1 LAMA3 CTSC EDEM1 LIF PIM3 
    PPARA SLC6A11 THNSL2 ZNF697) GROUP (drug_1) MANN_WHITNEY KRUSKAL_WALLIS(COMPARE=PAIRWISE) 
  /MISSING SCOPE=ANALYSIS USERMISSING=EXCLUDE
  /CRITERIA ALPHA=0.05  CILEVEL=95

Is there any way I can loop through the columns and perform the test without running the code block over and over again?

eli-k
  • 10,898
  • 11
  • 40
  • 44
Hadi Zafar
  • 31
  • 1

1 Answers1

1

One thing you can try is restructuring the file to long format so all the drugs are in one column, then you can run the test on all the drugs in parallele at once by splitting the file:

varstocases /make drugval from drug_1 to drug_338/index=drugname(drugval).
sort cases by drugname.
split file by drugname.
*now your code .
NPTESTS 
/INDEPENDENT TEST (PLIN3 CYFIP2 IL2RA HSD3B1 IL2RB PYROXD1 ZBED4 MCTP1 LAMA3 CTSC EDEM1 LIF PIM3 
    PPARA SLC6A11 THNSL2 ZNF697) GROUP (drugval) MANN_WHITNEY KRUSKAL_WALLIS(COMPARE=PAIRWISE) 
  /MISSING SCOPE=ANALYSIS USERMISSING=EXCLUDE
  /CRITERIA ALPHA=0.05  CILEVEL=95.
split file off.

Alternatively you can use SPSS macro to loop through all the drugs and test them one by one:

define testdrugs ()
!do !drg=1 !to 338
NPTESTS 
/INDEPENDENT TEST (PLIN3 CYFIP2 IL2RA HSD3B1 IL2RB PYROXD1 ZBED4 MCTP1 LAMA3 CTSC EDEM1 LIF PIM3 
    PPARA SLC6A11 THNSL2 ZNF697) GROUP !concat("(drug_", !drg, ")") MANN_WHITNEY KRUSKAL_WALLIS(COMPARE=PAIRWISE) 
  /MISSING SCOPE=ANALYSIS USERMISSING=EXCLUDE
  /CRITERIA ALPHA=0.05  CILEVEL=95
!doend
!enddefine.
* the macro is defined, now we can call it.
testdrugs .
eli-k
  • 10,898
  • 11
  • 40
  • 44