1. This is dataplot macro dexsp_write_factor_levels.dp 10/29/18 2. Purpose: Write out the factor levels for the dexsp.dp macros 3. Date: 10/29/18 4. Note: This routine is called by dexsp.dp 5. Input: 6. k (parameter) = number of factors 7. xplott, yplot, tagplot (vectors) = plot output vectors from previous dex mean plot 8. numlevva (vector) = number of levels of each factor 9. 10. Output: 11. Horzontal axis tic annotation gets wrrten out on an existing dex scatter plot 12. Note: When number of levels is moderate or large, 13. then an abbreviated annotation will be written out. 14. 15. -----start point----- 16. 17. print numlevva 18. pause 19. 20let bugswwfl = 0 21. let pausesw = 0 22. 23if bugswwfl = 1 24 print " "; print " "; print "At beginning of dexmp_write_factor_levels.dp" 25 print xplot yplot tagplot subset tagplot 1 to 99 26 print junk.out xplot yplot tagplot subset tagplot 1 to 99 27 if pausesw = 1; pause; end if 28 print "k = ^k" 29 if pausesw = 1; pause; end if 30 . print numlevva 31 . pause 32end if 33. 34. -----Step 1: extract out each (factor,level) combination----- 35. 36if bugswwfl = 1 37 print " "; print " "; print "At (dexspp_write_factor_levels.dp, step 1): extract xploti for each (factor,level) combinations" 38 if pausesw = 1; pause; end if 39end if 40. 41delete index1z indexz2 xplotz1 42tabulate mean xplot tagplot 43skip 1 44read dpst1f.dat indexz1 xplotz1 45. 46let numlevto = sum numlevva 47retain indexz1 xplotz1 for i = 1 1 numlevto 48. 49let numlevvc = cumulative sum numlevva 50let jstart = 0 51loop for jfact = 1 1 k 52 let numlevfa = numlevva(jfact) 53 let jstart = jstart + 1 54 let jstop = jstart + numlevfa -1 55 let indexz2 = ^jfact for i = jstart 1 jstop 56 let jstart = jstop 57 end loop 58. 59let xplot = xplotz1 60let tagplot = indexz2 61. 62if bugswwfl = 1; "At end of step 1:" 63 print xplot tagplot for i = 1 1 30 64 if pausesw = 1; pause; end if 65end if 66. 67. ----Step 2: Loop through the k factors, extract annotation strings and write them out----- 68. 69let yp = 18 70just center; hw 2 1 71. 72loop for jfact = 1 1 k 73 . 74 . -----Step 2.1: Form the annotation strings (if numlevfa >= 5, then smaller than numlevfa)----- 75 . 76 if bugswwfl = 1 77 print " "; print " "; print "======Step 2.1: jfact = ^jfact======"; 78 print "At (dexmp_write_factor_levels.dp, step 1): form annotation strings" 79 if pausesw = 1; pause; end if 80 end if 81 . 82 delete xpv indexv stoutv numlevfa 83 let xpv = xplot 84 retain xpv subset tagplot ^jfact 85 . 86 if bugswwfl = 1; print xpv 87 if pausesw = 1; pause; end if 88 end if 89 90 let numlevfa = number xpv 91 let indexv = 1 1 numlevfa 92 . 93 if bugswwfl = 1; print "numlevfa = ^numlevfa" 94 if pausesw = 1; pause; end if 95 print xpv indexv 96 if pausesw = 1; pause; end if 97 end if 98 . 99 if numlevfa = 1; let string stoutv = 1 ; end if 100 if numlevfa = 2; let string stoutv = - +; end if 101 if numlevfa = 3; let string stoutv = - 0 +; end if 102 if numlevfa = 4; let string stoutv = 1 2 3 4; end if 103 if numlevfa = 5; let string stoutv = 1 3 5; retain xpv indexv subset indexv 1 3 5; end if 104 if numlevfa = 6; let string stoutv = 1 . . 6; retain xpv indexv subset indexv 1 3 4 6; end if 105 if numlevfa = 7; let string stoutv = 1 3 5 7; retain xpv indexv subset indexv 1 3 5 7; end if 106 if numlevfa = 8; let string stoutv = 1 . . 8; retain xpv indexv subset indexv 1 4 5 8; end if 107 if numlevfa = 9; let string stoutv = 1 5 9; retain xpv indexv subset indexv 1 5 9; end if 108 if numlevfa = 10; let string stoutv = 1 4 7 10; retain xpv indexv subset indexv 1 4 7 10; end if 109 if numlevfa = 11; let string stoutv = 1 6 11; retain xpv indexv subset indexv 1 6 11; end if 110 if numlevfa = 12; let string stoutv = 1 5 8 12; retain xpv indexv subset indexv 1 5 8 12; end if 111 if numlevfa = 13; let string stoutv = 1 7 13; retain xpv indexv subset indexv 1 7 13; end if 112 if numlevfa = 14; let string stoutv = 1 5 10 14; retain xpv indexv subset indexv 5 10 14; end if 113 if numlevfa = 15; let string stoutv = 1 8 15; retain xpv indexv subset indexv 1 8 15; end if 114 if numlevfa = 16; let string stoutv = 1 . . 16; retain xpv indexv subset indexv 1 8 9 16; end if 115 if numlevfa >= 17; 116 let evenodd = mod(numlevfa,2) 117 if evenodd = 1 118 let midzz = (numlevfa + 1)/2 119 let string stoutv = 1 ^midzz ^numlevfa 120 retain xpv indexv subset indexv 1 ^midzz ^numlevfa 121 end if 122 if evenodd = 0 123 let midzz = (numlevfa)/2 124 let midzzm = midzz-1 125 let midzzp = midzz+1 126 let string stoutv = 1 ^midzzm ^midzzp ^numlevfa 127 retain xpv indexv subset indexv 1 ^midzzm ^midzzp ^numlevfa 128 end if 129 end if 130 . 131 . -----Step 2.2: Write out the strings----- 132 . 133 if bugswwfl = 1 134 print " "; print " "; print "At (dexmp_write_factor_levels.dp, step 2.2)" 135 print "jfact = ^jfact" 136 print xpv indexv 137 if pausesw = 1; pause; end if 138 end if 139 . 140 let nstoutv = number of words stoutv 141 if stoutv not exist 142 print "Error-stoutv not exists" 143 if pausesw = 1; pause; end if 144 end if 145 . 146 if bugswwfl = 1 147 print "stoutv = ^stoutv" 148 print "nstoutv = ^nstoutv" 149 if pausesw = 1; pause; end if 150 end if 151 152 loop for jword = 1 1 nstoutv 153 let stout = string word stoutv ^jword 154 let xp = xpv(^jword) 155 color blue; 156 if colorl exists 157 let ncolorl = number of words colorl 158 if jword <= ncolorl; let stcolorl = string word colorl ^jword; color ^stcolorl; end if 159 end if 160 moveds xp yp; text ^stout 161 end loop 162end loop 163. 164. -----Step 99: Finish up----- 165. 166if bugswwfl = 1 167 print " "; print " "; print "At end of dexmp_write_factor_levels.dp" 168 if pausesw = 1; pause; end if 169end if 170 171 172