Home ] Up ] Questionnaire Development ] CI3 ] MS Access ] [ SPSS ] SAS ] Word Perfect ] MapInfo ]

This code generates excel files, which are linked to MSWord to generate tables

for the reports that go out to school districts.

Data list File = 'C:\do_report_2k1\sdfs\test.sdf' TABLE
/v1 1-2 v2 3-5 v3 6 v4 7-8 v5 9-10 v6 11-12 v7 13-14
v8 15 v11 16 V103 17 V104 18 v107a 19 v107b 20 v106a 21 v106b 22 v18 23 v19 24
v21 to v23 25-27 v25 to v31 28-34 v33 to v34 35-36 v36 to v40 37-41 x01 to x06 42-47
v41 to v52 48-59 x07 to x09 60-62 v53 to v62 63-72 v111 to v116 73-78 v63 79 v65 80
v66 81 v68 82 v69 83 v71 84 v72 85 v74 86 v75 87 v77 88 v78 89 v80 90 x10 to x18 91-99
v81 100 v83 101 v84 102 v86 103 v87 104 v89 105 v90 106 v92 107 v93 108 v95 109 v96 110
v98 111 v99 112 v101 113 v102a 114 v102b 115 v102c 116 v102d 117 v102e 118 v102f 119 v102g 120
x19 121 v102h 122 v102i 123 v102j 124 v102k 125 v117 to v134 126-161 x20 to x22 162-167 v140 168
v141 169 v143 to v146 170-173 v148 174 v150 175 v152 to v154 176-178 x23 to x25 179-181
p01 to p14 182-195 v155 to v158 196-199 v159 to v165 200-206 x26 207 v166 to v172 208-214 x27 215
x28 216 v173 to v179 217-223 x29 224 v188 to v191 225-228 v191a 229 v192 to v195 230-233 v195a 234
v196 235 v8th 236-240 v10th 241-245 v12th 246-250.
EXECUTE.

MISSING VALUES ALL (9)/v1 v2 V4 TO V7 V117 TO V134 x20 to x22 (99).

recode v11 (3=8)(5=10)(7=12)(else=99) .
execute.

FILTER OFF.
USE ALL.
SELECT IF(v11 ~=99).
EXECUTE .

SAVE OUTFILE='c:\do_report_2k1\savs-flgs&rawdata\testno8-01rawdata.sav' /COMPRESSED.

SAVE OUTFILE='C:\do_report_2k1\zzzzz-01rawdata.sav' /COMPRESSED.

GET FILE='C:\do_report_2k1\reuse\00spacer.sav'.

*xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
*the following creates data for line 1 of table 1 .
GET FILE='c:\do_report_2k1\zzzzz-01rawdata.sav' /keep=v8th v10th v12th .
EXECUTE .

FILTER OFF.
use 1 thru 1 /permanent .
EXECUTE .

SAVE OUTFILE='c:\do_report_2k1\t01-line1.sav' .

* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
*this agg creates data for line 2 of table 1 .
GET FILE='c:\do_report_2k1\zzzzz-01rawdata.sav' .
sort cases by v11 .
AGGREGATE
/OUTFILE='c:\do_report_2k1\t01-line2.sav'
/presorted
/break=v11
/prtc=n .
GET FILE='c:\do_report_2k1\t01-line2.sav' .
FLIP VARIABLES= prtc /newname=v11 .
formats v8(F4) v10(F4) v12(F4) .
execute.

SAVE OUTFILE='c:\do_report_2k1\t01-line2.sav' .

GET FILE='c:\do_report_2k1\t01-line1.sav' /rename=(v8th v10th v12th=v8 v10 v12).
execute.

ADD FILES /FILE=*
/FILE='C:\do_report_2k1\t01-line2.sav' /RENAME (case_lbl = d0) /DROP= d0.
EXECUTE.

SAVE OUTFILE='c:\do_report_2k1\t01-lines1-2.sav' .

*2k1 works to here xxxxxxxxxxxxxxxxxxxxxx .
* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx .
* need to add usable and usable rate before flipping by getting big sav file and cleaning it .
* resulting sav file is equal to a flg file and can be used to generate remaining tables .

GET FILE='c:\do_report_2k1\zzzzz-01rawdata.sav' .

* setup counters for inconsistant and improbable answers.
compute incons=0.
compute improb=0.
EXECUTE.

* recode variables into sequences useable by the VECTOR command and .
* remember that the missing values for vector variables MUST be defined .
recode
v58 v63 v66 v69 v72 v75 v78 x10 x12 x14 v81 v84 v87 v90 v93 v96 v99
v60 v65 v68 v71 v74 v77 v80 x11 x13 x15 v83 v86 v89 v92 v95 v98 v101
(else=copy) into lif1 to lif17 ltd1 to ltd17.
MISSING VALUES all (9)/ lif1 to lif17 ltd1 to ltd17 (9).
execute.

* cleaning the data starts here .
compute flag=0.
vector iv=v58 to v60.
loop i=1 to 3.
if (v57=1 and iv(i)>=2) incons=incons+1.
end loop.
execute.

vector life=lif1 to lif17.
vector ltdt=ltd1 to ltd17.
loop i=1 to 17.
if (ltdt(i) >= 6) improb=improb+1.
loop j=1 to 6.
compute k=j+1.
if (life(i)=j and ltdt(i) >=k) incons=incons+1.
if (incons >= 3 or improb >= 4) flag=1.
end loop.
end loop.
execute.

FILTER OFF.
USE ALL.
SELECT IF(flag = 0).
EXECUTE .

save outfile= 'c:\do_report_2k1\zzzzz-02flag.sav' /keep=v1 to v196 .
execute.
save outfile= 'c:\do_report_2k1\testno8-02flag.sav' /keep=v1 to v196 .
execute.
* this saves the flag file for use in building other tables .

* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx .
* here begins building line4, needed to get line3.
* need numeric to compute percentages .

sort cases by v11 .
AGGREGATE
/OUTFILE='c:\do_report_2k1\t01-line4.sav'
/presorted
/break=v11
/usable=n .

GET FILE='c:\do_report_2k1\t01-lines1-2.sav'.
FLIP VARIABLES= v8 v10 v12 .

MATCH FILES /FILE=*
/FILE='c:\do_report_2k1\t01-line4.sav'.
EXECUTE.

DO IF (var001 = 99999) .
RECODE var001 var002 v11 usable (ELSE=SYSMIS) .
END IF .
EXECUTE .

compute rate=var002/var001*100 .
compute ublrate=usable/var002*100 .
formats rate (F4.1) ublrate (F4.1) .
execute .

SAVE OUTFILE='C:\do_report_2k1\t01step1.sav' /COMPRESSED.
FLIP VARIABLES=var001 var002 usable /NEWNAME=v11 .
formats v8 v10 v12 (F7.0).
save outfile= 'c:\do_report_2k1\t01-124.sav'.
SAVE TRANSLATE OUTFILE='C:\do_report_2k1\t01-124.xls'
/TYPE=XLS /MAP /REPLACE /FIELDNAMES.

GET FILE='c:\do_report_2k1\t01step1.sav'.
FLIP VARIABLES=rate ublrate /NEWNAME=v11 .
formats v8 v10 v12 (F7.1).
save outfile= 'c:\do_report_2k1\t01-35.sav'.
SAVE TRANSLATE OUTFILE='C:\do_report_2k1\t01-35.xls'
/TYPE=XLS /MAP /REPLACE /FIELDNAMES.

* this finishes data for tbl one.
* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx .
* below preps data for duplication of vax report tables 2 through 8 .
* fixes to the vax make the matches for indiv substances 100% .
* recode varis for t5 first.
* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx .

GET FILE='c:\do_report_2k1\zzzzz-02flag.sav'
/keep= v11 v103 v104 v106a v106b v53 to v62 v63 to v80 x10 to x18 v81 to v101 v117 to x22.
MISSING VALUES all (9)/ v117 to x22 (99) .
EXECUTE .

recode v11 (else=copy) into grade.
recode v104 (1=1)(6=2)(2 thru 5,7,8=3)(else=copy) into race.
recode v58 v59 v60 (else=copy) into alco1 alco2 alco3 .
recode v53 v54 v55 v56 (else=copy) into cigs1 cigs3 chew1 chew3 .
recode v63 v65 (else=copy) into pot1 pot3 .
EXECUTE.

do if (v57=1) .
+do if (alco1=9) .
+recode alco1 (9=1) (else=copy) .
+else if (alco1>=2 and alco1<=7) .
+recode alco1 (2 thru 7 =9) (else=copy) .
+end if .
+do if (alco2=9) .
+recode alco2 (9=1) (else=copy) .
+else if (alco2>=2 and alco2<=7) .
+recode alco2 (2 thru 7 =9) (else=copy) .
+end if .
+do if (alco3=9) .
+recode alco3 (9=1) (else=copy) .
+else if (alco3>=2 and alco3<=7) .
+recode alco3 (2 thru 7 =9) (else=copy) .
+end if .
else if (v57=2) .
+do if (alco1=1) .
+recode alco1 (1=9) (else=copy) .
+end if .
end if .
execute .

* vax now recodes all use variables; i'm leaving v58 to 60 alone need orig for t5 ; using alco1 to 3 .
* also need v53 to v56 cigs and chew and pot v65 orig for t5 .

recode cigs1 cigs3 chew1 chew3 pot1 pot3 v66 to v101 alco1 to alco3 (1=0)(2 thru 7=1)(else=sysmis) .
execute.

* next, the vax fixes lsd variables combining the two types .
* will use both types in all commands until ready to generate tables .
* then use the v69 v71 path = lft4 etc, and othlsd1 & 3.

if (v69=0 & v66=1) v69=1.
if (v71=0 & v68=1) v71=1.
execute .

* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 .
recode pot1 v72 v75 v69 v93 v87 v84 v81 v78 v90 alco1 cigs1 chew1 v96 x10 x12 x14 (else=copy) into li1 to li17.
recode pot3 v74 v77 v71 v95 v89 v86 v83 v80 v92 alco3 cigs3 chew3 v98 x11 x13 x15 (else=copy) into ld1 to ld17.
recode v122 v128 v129 v123 v132 v130 v127 v126 v125 v131 v120 v117 v119 v133 x22 x20 x21
(else=copy) into incon1 to incon17.
execute.

vector liftm= li1 to li17.
vector l3d=ld1 to ld17.
vector inc1= incon1 to incon17.
loop i=1 to 17.
-do if (v11=8 and inc1(i)>6 and inc1(i)<99) .
-compute liftm(i)= 9.
-compute l3d(i)= 9.
-end if .
+do if (v11=10 and inc1(i)>8 and inc1(i)<99) .
+compute liftm(i)= 9 .
+compute l3d(i)= 9.
+end if .
end loop.
execute .

do if (v11=8 and v120>6 and v120<99) .
compute alco2= 9.
end if .
do if (v11=10 and v120>8 and v120<99) .
compute alco2= 9.
end if .
execute .

recode li1 to li17 ld1 to ld17 v66 v68 v99 v101 (9=sysmis)(else=copy).
execute.

compute anyd1=sum(li1,v66,li4,li2,li3,li9,li8,li7,li6,li10,v99,li15,li16,li17).
compute nogr1=sum(v66,li4,li2,li3,li9,li8,li7,li6,li10,v99,li15,li16,li17).
compute anyd3=sum(ld1,v68,ld4,ld2,ld3,ld9,ld8,ld7,ld6,ld10,v101,ld15,ld16,ld17).
compute nogr3=sum(v68,ld4,ld2,ld3,ld9,ld8,ld7,ld6,ld10,v101,ld15,ld16,ld17).
execute.

recode anyd1 anyd3 nogr1 nogr3 (0=0)(1 thru hi=1).
execute.

* prep for tbl 5 .
* need to fix alco vari v60 and 62.

recode v60 (else=copy) into alcdly.
recode v62 (else=copy) into alc5 .
execute.
do if (v57=1) .
+do if (alcdly=9) .
+recode alcdly (9=1) (else=copy) .
+else if (alcdly>=2 and alcdly<=7) .
+recode alcdly (2 thru 7 =9) (else=copy) .
+end if .
+do if (alc5=9) .
+recode alc5 (9=1) (else=copy) .
+else if (alc5>=2 and alc5<=7) .
+recode alc5 (2 thru 7 =9) (else=copy) .
+end if .
end if .
execute .

recode v65 alcdly (1 thru 5=0) (6,7=1)(9=sysmis) into potdly alcodly .
execute.
recode alc5 (1=0) (2 thru 6=1)(9=sysmis) into alco5 .
execute.
recode v54 (1,2=0) (3 thru 7=1)(9=sysmis) into cigsdly .
execute.
recode v54 (1 thru 3=0) (4 thru 7=1)(9=sysmis) into cighalf .
execute.
recode v56 (1 thru 4=0) (5,6=1)(9=sysmis) into chewdly .
EXECUTE .

* now give substances easier to use names .
rename variables (li1 to li17 = pot1a crack1 coke1 othlsd1 inhal1 herion1 tranq1 barb1
amph1 othnar1 alcoh1 cigs1a chew1a sterio1 meth1 xtc1 roh1)
(ld1 to ld17=pot3a crack3 coke3 othlsd3 inhal3 herion3 tranq3 barb3
amph3 othnar3 alcoh3 cigs3a chew3a sterio3 meth3 xtc3 roh3) .
execute .

* now have data ready to use in tables 2-7 .

SAVE OUTFILE='c:\do_report_2k1\03dataplusvectors.sav' /COMPRESSED.

GET FILE='c:\do_report_2k1\reuse\00spacer.sav'.

* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx .
* start here to dup tables 2 - 7 .
* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx .

GET FILE='c:\do_report_2k1\03dataplusvectors.sav'
/keep=grade v103 race v106a
anyd1 nogr1 pot1a crack1 coke1 othlsd1 inhal1 herion1 tranq1 barb1 amph1 othnar1 alcoh1 cigs1a chew1a sterio1 meth1 xtc1 roh1
anyd3 nogr3 pot3a crack3 coke3 othlsd3 inhal3 herion3 tranq3 barb3 amph3 othnar3 alcoh3 cigs3a chew3a sterio3 meth3 xtc3 roh3
potdly alcodly alco5 cigsdly cighalf chewdly.
EXECUTE .

SAVE OUTFILE='C:\do_report_2k1\04substancesonly.sav' /COMPRESSED.

* this is for tbl 2, lifetime use ******************************************.
AGGREGATE
/OUTFILE='c:\do_report_2k1\t02life.sav'
/BREAK=grade
/anyd1_1 = PGT(anyd1 0) /nogr1_1 = PGT(nogr1 0) /pot1a_1 = PGT(pot1a 0)
/crack1_1 = PGT(crack1 0) /coke1_1 = PGT(coke1 0) /othlsd_1 = PGT(othlsd1 0)
/inhal1_1 = PGT(inhal1 0) /herion_1 = PGT(herion1 0) /tranq1_1 = PGT(tranq1 0)
/barb1_1 = PGT(barb1 0) /amph1_1 = PGT(amph1 0) /othnar_1 = PGT(othnar1 0)
/alcoh1_1 = PGT(alcoh1 0) /cigs1a_1 = PGT(cigs1a 0) /chew1a_1 = PGT(chew1a 0)
/sterio_1 = PGT(sterio1 0) /meth1_1 = PGT(meth1 0) /xtc1_1 = PGT(xtc1 0) /roh1_1 = PGT(roh1 0)
/N_BREAK=N.

* this is for tbl 3, last 30 days ******************************************.
AGGREGATE
/OUTFILE='c:\do_report_2k1\t03day.sav'
/BREAK= grade
/anyd3_1 = PGT(anyd3 0) /nogr3_1 = PGT(nogr3 0) /pot3a_1 = PGT(pot3a 0) /crack3_1 = PGT(crack3 0)
/coke3_1 = PGT(coke3 0) /othlsd_1 = PGT(othlsd3 0) /inhal3_1 = PGT(inhal3 0) /herion_1 = PGT(herion3 0)
/tranq3_1 = PGT(tranq3 0) /barb3_1 = PGT(barb3 0) /amph3_1 = PGT(amph3 0) /othnar_1 = PGT(othnar3 0)
/alcoh3_1 = PGT(alcoh3 0) /cigs3a_1 = PGT(cigs3a 0) /chew3a_1 = PGT(chew3a 0) /sterio_1 = PGT(sterio3 0)
/meth3_1 = PGT(meth3 0) /xtc3_1 = PGT(xtc3 0) /roh3_1 = PGT(roh3 0)
/N_BREAK=N.

* this is for tbl 4, heavy use ******************************************.
AGGREGATE
/OUTFILE='c:\do_report_2k1\t04hvy.sav'
/BREAK=grade
/potdly_1 = PGT(potdly 0) /alcodl_1 = PGT(alcodly 0) /alco5_1 = PGT(alco5 0)
/cigsdl_1 = PGT(cigsdly 0) /cighal_1 = PGT(cighalf 0) /chewdl_1 = PGT(chewdly 0)
/N_BREAK=N.

* this is for table 5 gender diffs.
AGGREGATE
/OUTFILE='C:\do_report_2k1\t05gdr.sav'
/BREAK=grade v103
/anyd3_1 = PGT(anyd3 0) /nogr3_1 = PGT(nogr3 0) /pot3a_1 = PGT(pot3a 0) /crack3_1 = PGT(crack3 0)
/coke3_1 = PGT(coke3 0) /othlsd_1 = PGT(othlsd3 0) /inhal3_1 = PGT(inhal3 0) /herion_1 = PGT(herion3 0)
/tranq3_1 = PGT(tranq3 0) /barb3_1 = PGT(barb3 0) /amph3_1 = PGT(amph3 0) /othnar_1 = PGT(othnar3 0)
/alcoh3_1 = PGT(alcoh3 0) /cigs3a_1 = PGT(cigs3a 0) /chew3a_1 = PGT(chew3a 0) /sterio_1 = PGT(sterio3 0)
/meth3_1 = PGT(meth3 0) /xtc3_1 = PGT(xtc3 0) /roh3_1 = PGT(roh3 0)
/N_BREAK=N.

* this is for table 6 racial diffs******************************************.
AGGREGATE
/OUTFILE='C:\do_report_2k1\t06rac.sav'
/BREAK=grade race
/anyd3_1 = PGT(anyd3 0) /nogr3_1 = PGT(nogr3 0) /pot3a_1 = PGT(pot3a 0) /crack3_1 = PGT(crack3 0)
/coke3_1 = PGT(coke3 0) /othlsd_1 = PGT(othlsd3 0) /inhal3_1 = PGT(inhal3 0) /herion_1 = PGT(herion3 0)
/tranq3_1 = PGT(tranq3 0) /barb3_1 = PGT(barb3 0) /amph3_1 = PGT(amph3 0) /othnar_1 = PGT(othnar3 0)
/alcoh3_1 = PGT(alcoh3 0) /cigs3a_1 = PGT(cigs3a 0) /chew3a_1 = PGT(chew3a 0) /sterio_1 = PGT(sterio3 0)
/meth3_1 = PGT(meth3 0) /xtc3_1 = PGT(xtc3 0) /roh3_1 = PGT(roh3 0)
/N_BREAK=N.

* this is for table 7 college bound diffs; first recode v106a *****************************************.
recode v106a (1,2=2)(3,4=1)(else=copy).
execute.
AGGREGATE
/OUTFILE='C:\do_report_2k1\t07cb.sav'
/BREAK=grade v106a
/anyd3_1 = PGT(anyd3 0) /nogr3_1 = PGT(nogr3 0) /pot3a_1 = PGT(pot3a 0) /crack3_1 = PGT(crack3 0)
/coke3_1 = PGT(coke3 0) /othlsd_1 = PGT(othlsd3 0) /inhal3_1 = PGT(inhal3 0) /herion_1 = PGT(herion3 0)
/tranq3_1 = PGT(tranq3 0) /barb3_1 = PGT(barb3 0) /amph3_1 = PGT(amph3 0) /othnar_1 = PGT(othnar3 0)
/alcoh3_1 = PGT(alcoh3 0) /cigs3a_1 = PGT(cigs3a 0) /chew3a_1 = PGT(chew3a 0) /sterio_1 = PGT(sterio3 0)
/meth3_1 = PGT(meth3 0) /xtc3_1 = PGT(xtc3 0) /roh3_1 = PGT(roh3 0)
/N_BREAK=N.

* this is for tbl 2, lifetime use ******************************************.
GET FILE='c:\do_report_2k1\t02life.sav'.
FLIP VARIABLES=n_break anyd1_1 nogr1_1 pot1a_1 crack1_1 coke1_1 othlsd_1 inhal1_1
herion_1 tranq1_1 barb1_1 amph1_1 othnar_1 alcoh1_1 cigs1a_1 chew1a_1 sterio_1 meth1_1 xtc1_1 roh1_1
/NEWNAME=grade .

SAVE OUTFILE='C:\do_report_2k1\t02lifedone.sav' /COMPRESSED.
SAVE TRANSLATE OUTFILE='C:\do_report_2k1\t02lifedone.xls'
/TYPE=XLS /MAP /REPLACE /FIELDNAMES.

* this is for tbl 3, last 30 days ******************************************.
GET FILE='c:\do_report_2k1\t03day.sav'.
FLIP VARIABLES=n_break anyd3_1 nogr3_1 pot3a_1 crack3_1 coke3_1 othlsd_1 inhal3_1
herion_1 tranq3_1 barb3_1 amph3_1 othnar_1 alcoh3_1 cigs3a_1 chew3a_1 sterio_1 meth3_1 xtc3_1 roh3_1
/NEWNAME=grade .
SAVE OUTFILE='c:\do_report_2k1\t03daydone.sav' /COMPRESSED.
SAVE TRANSLATE OUTFILE='C:\do_report_2k1\t03daydone.xls'
/TYPE=XLS /MAP /REPLACE /FIELDNAMES.

* this is for tbl 4, heavy use ******************************************.
GET FILE='c:\do_report_2k1\t04hvy.sav'.
FLIP VARIABLES=n_break potdly_1 alcodl_1 alco5_1 cigsdl_1 cighal_1 chewdl_1
/NEWNAME=grade .
SAVE OUTFILE='c:\do_report_2k1\t04hvydone.sav' /COMPRESSED.
SAVE TRANSLATE OUTFILE='C:\do_report_2k1\t04hvydone.xls'
/TYPE=XLS /MAP /REPLACE /FIELDNAMES.

* this is for tbl 5 gender diffs ******************************************.
GET FILE='c:\do_report_2k1\t05gdr.sav'.
FILTER OFF.
USE ALL.
SELECT IF(v103 ~= 9).
EXECUTE .
SORT CASES BY grade (A) .

MATCH FILES /FILE=*
/FILE='C:\do_report_2k1\reuse\00fake gndr cases.sav'
/BY grade v103.
EXECUTE.

FLIP VARIABLES=n_break anyd3_1 nogr3_1 pot3a_1 crack3_1 coke3_1 othlsd_1 inhal3_1
herion_1 tranq3_1 barb3_1 amph3_1 othnar_1 alcoh3_1 cigs3a_1 chew3a_1 sterio_1 meth3_1 xtc3_1 roh3_1
/NEWNAME=grade .
SAVE OUTFILE='c:\do_report_2k1\t05gdr-step1.sav' /COMPRESSED.
GET FILE='c:\do_report\reuse\00spacer.sav' .
GET FILE='c:\do_report_2k1\t05gdr-step1.sav'
keep=case_lbl v8.0 v8.01 v10.0 v10.01 v12.0 v12.01 .
execute.

SAVE OUTFILE='c:\do_report_2k1\t05gdrdone.sav' /COMPRESSED.
SAVE TRANSLATE OUTFILE='C:\do_report_2k1\t05gdrdone.xls'
/TYPE=XLS /MAP /REPLACE /FIELDNAMES .
GET FILE='c:\do_report\reuse\00spacer.sav' .

GET FILE='c:\do_report_2k1\t05gdrdone.sav'.
FILTER OFF.
use 1 thru 1 /permanent .
EXECUTE .
formats v8.0(F5) v8.01(F5) v10.0(F5) v10.01(F5) v12.0(F5) v12.01(F5).
SAVE OUTFILE='c:\do_report_2k1\t05gdrcnt.sav' /COMPRESSED.
SAVE TRANSLATE OUTFILE='C:\do_report_2k1\t05gdrcnt.xls'
/TYPE=XLS /MAP /REPLACE /FIELDNAMES.

* this is for tbl 6 race diffs ******************************************************************.
* get the t07 file, recode using do if, sort by race, save it keeping same name .
* then get fake race file and merge them with both providing cases.

GET FILE='c:\do_report_2k1\t06rac.sav'.

FILTER OFF.
USE ALL.
SELECT IF(race ~= 9).
EXECUTE .

DO IF (n_break < 25) .
RECODE anyd3_1 to roh3_1 (ELSE=sysmis) .
END IF .
EXECUTE .

SORT CASES BY grade (A) .
SAVE OUTFILE='c:\do_report_2k1\t06rac2.sav' /COMPRESSED.

MATCH FILES /FILE=*
/FILE='C:\do_report_2k1\reuse\00fake race cases.sav'
/BY grade race.
EXECUTE.

RECODE n_break (SYSMIS=0) .
execute.

FLIP VARIABLES=n_break anyd3_1 nogr3_1 pot3a_1 crack3_1 coke3_1 othlsd_1 inhal3_1
herion_1 tranq3_1 barb3_1 amph3_1 othnar_1 alcoh3_1 cigs3a_1 chew3a_1 sterio_1 meth3_1 xtc3_1 roh3_1
/NEWNAME=grade .
SAVE OUTFILE='c:\do_report_2k1\t06rac3.sav' /COMPRESSED.
GET FILE='c:\do_report\reuse\00spacer.sav' .
GET FILE='c:\do_report_2k1\t06rac3.sav'
keep=case_lbl v8.0 v8.01 v8.02 v10.0 v10.01 v10.02 v12.0 v12.01 v12.02 .
execute.
SAVE OUTFILE='c:\do_report_2k1\t06racdone.sav' /COMPRESSED.
SAVE TRANSLATE OUTFILE='C:\do_report_2k1\t06racdone.xls'
/TYPE=XLS /MAP /REPLACE /FIELDNAMES.

FILTER OFF.
use 1 thru 1 /permanent .
EXECUTE .
formats v8.0(F5) v8.01(F5) v8.02(F5) v10.0(F5) v10.01(F5) v10.02(F5)
v12.0(F5) v12.01(F5) v12.02(F5).

DO IF (v8.0 = 0 & v8.01 = 0 & v8.02 = 0) .
RECODE v8.0 v8.01 v8.02 (0=SYSMIS) .
else if (v10.0 = 0 & v10.01 = 0 & v10.02 = 0) .
RECODE v10.0 v10.01 v10.02 (0=SYSMIS) .
else if (v12.0 = 0 & v12.01 = 0 & v12.02 = 0) .
RECODE v12.0 v12.01 v12.02 (0=SYSMIS) .
END IF .
EXECUTE .

SAVE OUTFILE='c:\do_report_2k1\t06raccnt.sav' /COMPRESSED.
SAVE TRANSLATE OUTFILE='C:\do_report_2k1\t06raccnt.xls'
/TYPE=XLS /MAP /REPLACE /FIELDNAMES.

* this is for tbl 7 college bound diffs **********************************************************.
GET FILE='c:\do_report_2k1\t07cb.sav'.
FILTER OFF.
USE ALL.
SELECT IF(v106a ~= 9).
EXECUTE .
SORT CASES BY grade (A) .

MATCH FILES /FILE=*
/FILE='C:\do_report_2k1\reuse\00fake cbnb cases.sav'
/BY grade v106a.
EXECUTE.

FLIP VARIABLES=n_break v106a anyd3_1 nogr3_1 pot3a_1 crack3_1 coke3_1 othlsd_1 inhal3_1
herion_1 tranq3_1 barb3_1 amph3_1 othnar_1 alcoh3_1 cigs3a_1 chew3a_1 sterio_1 meth3_1 xtc3_1 roh3_1
/NEWNAME=grade .
SAVE OUTFILE='c:\do_report_2k1\t07cb-flipped.sav' /COMPRESSED.
GET FILE='c:\do_report\reuse\00spacer.sav' .
GET FILE='c:\do_report_2k1\t07cb-flipped.sav'
/keep=case_lbl v8.0 v8.01 v10.0 v10.01 v12.0 v12.01 .
execute.
SAVE OUTFILE='c:\do_report_2k1\t07cbdone.sav' /COMPRESSED.
SAVE TRANSLATE OUTFILE='C:\do_report_2k1\t07cbdone.xls'
/TYPE=XLS /MAP /REPLACE /FIELDNAMES.

FILTER OFF.
use 1 thru 1 /permanent .
EXECUTE .
formats v8.0(F5) v8.01(F5) v10.0(F5) v10.01(F5) v12.0(F5) v12.01(F5).
SAVE OUTFILE='c:\do_report_2k1\t07cbcnt.sav' /COMPRESSED.
SAVE TRANSLATE OUTFILE='C:\do_report_2k1\t07cbcnt.xls'
/TYPE=XLS /MAP /REPLACE /FIELDNAMES.

include file='c:\do_report_2k1\coms\t080910.sps'.

include file='c:\do_report_2k1\coms\t1127.sps'.

include file='c:\do_report_2k1\coms\tapp81012.sps'.

include file='c:\do_report_2k1\coms\tapphvyd.sps'.

include file='c:\do_report_2k1\coms\tappmarj.sps'.

include file='c:\do_report_2k1\coms\tappothr.sps'.

GET FILE='C:\do_report_2k1\tapp-part1done.sav'.
MATCH FILES /FILE=*
/FILE='C:\do_report_2k1\tapp-heavydone.sav'
/RENAME (case_lbl = d0)
/DROP= d0.
EXECUTE.
MATCH FILES /FILE=*
/FILE='C:\do_report_2k1\tapp-marjdone.sav'
/RENAME (case_lbl = d0)
/DROP= d0.
EXECUTE.
MATCH FILES /FILE=*
/FILE='C:\do_report_2k1\tapp-othrdone.sav'
/RENAME (case_lbl = d0)
/DROP= d0.
EXECUTE.
SAVE OUTFILE='C:\do_report_2k1\tapp-done.sav' /COMPRESSED.
SAVE TRANSLATE OUTFILE='C:\do_report_2k1\tappdone.xls'
/TYPE=XLS /MAP /REPLACE /FIELDNAMES.

GET FILE='C:\do_report_2k1\tapp-done.sav'.
FILTER OFF.
use 1 thru 1 /permanent .
EXECUTE .

recode v8 v10 v12 hvy marj othrd (10=sysmis) .
execute.

formats v8(F5) v10(F5) v12(F5) hvy(F5) marj(F5) othrd(F5) .
execute.
compute v8pc=v8/v8*100.
compute v10pc=v10/v10*100.
compute v12pc=v12/v12*100.
compute hvypc=hvy/hvy*100.
compute marjpc=marj/marj*100.
compute othrdpc=othrd/othrd*100.
execute.
SAVE OUTFILE='C:\do_report_2k1\tapp-cnt.sav' /COMPRESSED.
SAVE TRANSLATE OUTFILE='C:\do_report_2k1\tappcnt.xls'
/TYPE=XLS /MAP /REPLACE /FIELDNAMES.

Home ] Up ] Questionnaire Development ] CI3 ] MS Access ] [ SPSS ] SAS ] Word Perfect ] MapInfo ]