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

 /* read in parameter file to set up job and librefs for national stats */
%include jsetup;
/*Table 1*/
*students participating in survey, Line 2, Table 1;
proc freq data=d.t&school;
tables grade/out=spart noprint;
run;
  proc transpose data=spart out=spart prefix=spart;
  var count;
  id grade;
*response rates, Line 3, Table 1;
data rrates;
merge d.r&school spart;
rate8=spart8/grade8 *100;
rate10=spart10/grade10 *100;
rate12=spart12/grade12 *100;
keep rate8 rate10 rate12;
run;
*usable questionaire rates, Line 5, Table 1;
data qrate;
merge d.n&school spart;
grade8=(grade8/spart8)*100;
grade10=(grade10/spart10)*100;
grade12=(grade12/spart12)*100;
run;
proc datasets library=work;
modify spart;
  rename spart8=grade8 spart10=grade10 spart12=grade12;
modify rrates;
  rename rate8=grade8 rate10=grade10 rate12=grade12;
run;
/*data set for table 1 from raw data */
data all;
set d.r&school spart rrates d.n&school qrate;
run;
data _null_;
file pone12 print header=h ps=55 notitles n=ps;
merge all n.nt1 end=last;
if _n_= 1 or _n_=2 then put _n_ nn.
     @38 grade8 fr. @48 grade10 fr. @58 grade12 fr. @68 ngrade12
  fr. /;
else if _n_=3 or _n_=5 then put _n_ nn.
     @42 grade8 per. @52 grade10 per. @62 grade12  per. @72 ngrade12 per. /;
else if _n_=4 then  put  _n_ nn.
     @42 grade8 fr. @52 grade10 fr. @62 grade12 fr. @72  ngrade12 fr. /;
if last then goto foot;
return;
h: put @35 'TABLE 1' //
       @26 'SAMPLES AND RESPONSE RATES'//
     @68 'National^L1^K'/
     @38 ' Grade ' @48 ' Grade ' @58 ' Grade ' @68 ' Grade '  /
     @38 '   8   ' @48 '   10  ' @58 '   12  ' @68 '   12  ' /
     @38 '^L^L_______' @52 '_______' @62 '_______' @72 '_______^K^K'/;
return;
foot: put /' ' / ' '  / ' ' / ' '/  ' '/  ' '/ #34
'^L1^K"National Grade 12" is based on The National High School Senior Survey'
/ ' (Monitoring the Future) conducted by the Institute of Social Research,'
/ " University of Michigan, Spring 19&yr.." //
'^L2^KThe response rate is the percent of students who responded to the'/
' questionnaire based on your estimate of enrollment provided at the time of'/
' the survey in your school district for each grade.  Non-response may be'/
' due to prior non-consent by the parents, or non-consent by the student at'/
' at the time of the survey or absence at time of survey administration.'//
'^L3^K"Usable Questionnaires" are those in which an internal analysis of '/
' the questionnaires reveals that the respondent did not answer questions with'/
' impossible or highly unlikely responses.'//
'^L4^KThe "Usable Questionnaire Rate" is the percentage of students participating'/
' whose questionaires contained no impossible or unlikely responses.  These'/
' questionnaires form the basis for all subsequent data analysis.'
#54 @36 '9';
return;
run;
/* Tables 2,3,4,5,6,7,7a,8*/
  /* count number of students who have never used alcohol */
  /* to add in later to no use alcohol counts             */
proc freq data=d.&school;
tables v57*grade / out=noalc noprint;
where v57=1;
run;
   proc transpose data=noalc out=d.a&school;
   var count;
   id grade;
   run;
  /*Data set to use to construct percentages for tables */
data idrugs (keep=grade v103 v104 tframe sg cg rg mg cbound
                  anydrug nograss grass crack
                  coke lsd inhal heroin tranq
                  barb amph narc alcohol cigs
                  chew steroids
             rename=(v103=sex));
set d.&school;
*set up array of variables to classify cases;
array recode {49} v53-v101;
*set up alcohol variable;
select (v57);
  when (1) do;
    if v58=. then v58=1; *set lifetime use to 0 occassions;
    else if v58 gt 1 then v58=.;  *omit, inconsistant answer;
    if v59=. then v59=1; *set pastyear use to 0 occassions;
    else if v59 gt 1 then v59=.; *omit, inconsistant answer;
    if v60=. then v60=1;  *set past30day use to 0 occassions;
    else if v60 gt 1 then v60=.; * omit, inconsistant answer;
    end;
  when (2) do;
    if v58=1 then v58=.; *omit, inconsistant answer;
    end;
  otherwise;
end;
*set up sex by grade variable;
     if v103=1 and grade=8 then sg=1;
else if v103=2 and grade=8 then sg=2;
else if v103=1 and grade=10 then sg=3;
else if v103=2 and grade=10 then sg=4;
else if v103=1 and grade=12 then sg=5;
else if v103=2 and grade=12 then sg=6;
*set up college bound by grade variable;
if 1<= v106 <= 2  then  cbound=0;
else if 3<= v106 <= 4 then cbound=1;
     if grade=8 and cbound=1 then cg=1;
else if grade=8 and cbound=0 then cg=2;
else if grade=10 and cbound=1 then cg=3;
else if grade=10 and cbound=0 then cg=4;
else if grade=12 and cbound=1 then cg=5;
else if grade=12 and cbound=0 then cg=6;
*set up race by grade variables;
     if v104=1 or 3<=v104<=5 or v104=7 then race=3;  *other;
else if v104=2 then race=1;                          *black;
else if v104=6 then race=2;                          *white;
     if race=1 and grade=8 then mg=1;
else if race=2 and grade=8 then mg=2;
else if race=3 and grade=8 then mg=3;
else if race=1 and grade=10 then mg=4;
else if race=2 and grade=10 then mg=5;
else if race=3 and grade=10 then mg=6;
else if race=1 and grade=12 then mg=7;
else if race=2 and grade=12 then mg=8;
else if race=3 and grade=12 then mg=9;
else mg=.;
     if v104=2 and grade=8 then rg=1;
else if v104=6 and grade=8 then rg=2;
else if v104=1 and grade=8 then rg=3;
else if v104=3 and grade=8 then rg=4;
else if v104=4 and grade=8 then rg=5;
else if v104=5 and grade=8 then rg=6;
else if v104=7 and grade=8 then rg=7;
else if v104=2 and grade=10 then rg=8;
else if v104=6 and grade=10 then rg=9;
else if v104=1 and grade=10 then rg=10;
else if v104=3 and grade=10 then rg=11;
else if v104=4 and grade=10 then rg=12;
else if v104=5 and grade=10 then rg=13;
else if v104=7 and grade=10 then rg=14;
else if v104=2 and grade=12 then rg=15;
else if v104=6 and grade=12 then rg=16;
else if v104=1 and grade=12 then rg=17;
else if v104=3 and grade=12 then rg=18;
else if v104=4 and grade=12 then rg=19;
else if v104=5 and grade=12 then rg=20;
else if v104=7 and grade=12 then rg=21;
else rg=.;
*classify case:  drug not used=0, drug used=1;
do i=1 to 49;
 if recode{i}=1 then recode{i}=0;
 else  if recode{i} ge 2 then recode{i}=1;
 else recode{i}=.;
end;
*fix lsd variables;
 if v69=0 and v66=1 then v69=1;
 if v70=0 and v67=1 then v70=1;
 if v71=0 and v68=1 then v71=1;
*arrays to calculate anyuse and only mj variables;
array lifetime {14} v63 v72 v75 v69 v93 v87 v84 v81 v78
                    v90 v58 v53 v55 v96;
array pastyear {12} v64 v73 v76 v70 v94 v88 v85 v82 v79
                    v91 v59 v97;
array past30da {14} v65 v74 v77 v71 v95 v89 v86 v83 v80
                    v92 v60 v54 v56 v98;
array results {14} grass crack coke lsd inhal heroin tranq barb amph
                   narc alcohol cigs chew steroids;
array table3 {12} grass crack coke lsd inhal heroin tranq barb amph
                   narc alcohol steroids;
array incons1 {14} v122 v128 v129 v123 v132 v130 v127 v126 v125
                   v131 v120 v117 v119 v133;
array incons2 {12} v122 v128 v129 v123 v132 v130 v127 v126 v125
                   v131 v120 v133;
/* Lifetime use variables */
 *fix inconsistant answers for lifetime use ;
  do i=1 to 14;
    if grade=8 and incons1{i} gt 5 then lifetime{i}=.;
    if grade=10 and incons1{i} gt 7 then lifetime{i}=.;
    results{i}=lifetime{i};
    end;
  *calculate anydrug use type variables;
  anydrug=sum(v63,v66,v69,v72,v75,v78,v81,v84,v87,v90,v99);
  nograss=sum(v66,v69,v72,v75,v78,v81,v84,v87,v90,v99);
  if anydrug gt 0 then anydrug=1;
  if nograss gt 0 then nograss=1;
  tframe=1;  output;
/* Past year variables  */
  *fix inconsistant answers;
   do j=1 to 12;
     if grade=8 and incons1{j} gt 5 then pastyear{j}=.;
     if grade=10 and incons1{j} gt 7 then pastyear{j}=.;
     table3{j}=pastyear{j};
     end;
  *calculate anydrug use type variabls;
  anydrug=sum(v64,v67,v70,v73,v76,v79,v82,v85,v88,v91,v100);
  nograss=sum(v67,v70,v73,v76,v79,v82,v85,v88,v91,v100);
  if anydrug gt 0 then anydrug=1;
  if nograss gt 0 then nograss=1;
  tframe=2;
  output;
/* Past month variables */
  *fix inconsistant answers;
  do k=1 to 14;
     if grade=8 and incons1{k} gt 5 then past30da{k}=.;
     if grade=10 and incons1{k} gt 7 then past30da{k}=.;
     results{k}=past30da{k};
     end;
  *calculate anydrug use type variables;
  anydrug=sum(v65,v68,v71,v74,v77,v80,v83,v86,v89,v92,v101);
  nograss=sum(v68,v71,v74,v77,v80,v83,v86,v89,v92,v101);
  if nograss gt 0 then nograss=1;
  if anydrug gt 0 then anydrug=1;
  tframe=3; output;
run;
/* set up line 1 of table */
data tframen;
set d.n&school;
tframe=1; output; tframe=2; output; tframe=3; output;
run;
proc sort; by tframe;
/* Freqs for tables 2,3,4 */
proc sort data=idrugs; by tframe;
proc summary data=idrugs;
class grade;
var anydrug nograss grass crack coke lsd inhal heroin tranq
    barb amph narc alcohol cigs chew steroids;
output out=idrugsum sum=anydrug nograss grass crack coke
                        lsd inhal heroin tranq barb amph narc
                        alcohol cigs chew steroids
                      n=nanydrug nnograss ngrass ncrack ncoke
                        nlsd ninhal nheroin ntranq nbarb namph nnarc
                        nalcohol ncigs nchew nsterods;
by tframe;
run;
     data idrugsum;
     set idrugsum;
     by tframe;
     if _type_=1;
     array freq {16} anydrug nograss grass crack coke
           lsd inhal heroin tranq barb amph narc alcohol cigs
           chew steroids;
     array n {16} nanydrug nnograss ngrass ncrack ncoke
             nlsd ninhal nheroin ntranq nbarb namph nnarc
             nalcohol ncigs nchew nsterods;
     array percent {16} anydrug nograss grass crack coke
           lsd inhal heroin tranq barb amph narc alcohol cigs
           chew steroids;
     do i=1 to 16;
       percent{i}=round((freq{i}/n{i})*100,.1);
     end;
     drop nanydrug nnograss ngrass ncrack ncoke
          nlsd ninhal nheroin ntranq nbarb namph nnarc
          nalcohol ncigs nchew nsterods;
     run;
     proc transpose data=idrugsum out=sumidrug prefix=grade;
     var anydrug nograss grass crack coke lsd inhal heroin
         tranq barb amph narc alcohol cigs chew steroids;
     id grade;
     by tframe;
/* n's and percents */
data sumidrug;
set tframen sumidrug;
by tframe;
run;
*proc sort data=n.nt2t4; *by tframe;
data _null_;
merge n.nt2t4 sumidrug end=last;
by tframe;
if tframe=2 and (question=15 or question=16) then delete;
if _n_=1 then do;
  number=2;
  pageno=13;
end;
file pone12 print notitles ps=55 mod n=ps;
if first.tframe then link h;
if question=1 then put question idrug.
   @37 grade8 hfreq. @47 grade10 hfreq. @57 grade12 hfreq.
   @67 ngrade12 hfreq. /;
else if question=2 or question=13 then put question idrug.
   @43 grade8 num. @53 grade10 num. @63 grade12 num.
   @73 ngrade12 num. /;
else if question=3 then put 'Any Illicit Drug Use' / @2 question idrug.
   @43 grade8 num. @53 grade10 num. @63 grade12 num.
   @73 ngrade12 num.  /;
else if question=9 or question=14 then put question idrug.
   @39 grade8 num. @49 grade10 num. @59 grade12 num.
   @69 ngrade12 num./ ;
else if 10 <= question <=12 then put question idrug.
   @43 grade8 num. @53 grade10 num. @63 grade12 num.
   @73 ngrade12 num. ;
else if question=16 then put question idrug.
    @39 grade8 num. @49 grade10 num. @59 grade12 num.
    @69 ngrade12 num./;
else put question idrug.
    @39 grade8 num. @49 grade10 num. @59 grade12 num.
    @69 ngrade12 num.;
if last.tframe then do;
  link foot;
  number+1;
  pageno+1;
end;
if last then stop;
return;
h: select (number);
  when(2) put @35 'TABLE ' number 1.//
              @25 'LIFETIME USE OF VARIOUS DRUGS'//
              @15 '(Entries are Percent Using the Drug In Lifetime)'/;
  when(3) put _page_ @36 'TABLE ' number 1.//
              @25 'PAST-YEAR USE OF VARIOUS DRUGS' //
              @14 '(Entries are Percent Using the Drug In Prior 12 Months)'/;
  when(4) put _page_ @36 'TABLE ' number 1. //
              @24 'PAST-MONTH USE OF VARIOUS DRUGS'//
              @14 '(Entries are Percent Using the Drug In Past 30 Days)' /;
  otherwise;
  end;
put  @68 'National^L1^K'/
     @38 ' Grade ' @48 ' Grade ' @58 ' Grade ' @68 ' Grade '  /
     @38 '   8   ' @48 '   10  ' @58 '   12  ' @68 '   12  ' /
     @38 '^L^L_______' @52 '_______' @62 '_______' @72 '_______^K^K'/;
return;
foot:
put /' ' / ' ' / ' ' #40
'^L1^K"National Grade 12" is based on The National High School Senior Survey'
/ ' (Monitoring the Future) conducted by the Institute of Social Research,'
/ " University of Michigan, Spring 19&yr.." //
'^L2^KIncludes the use of any drug on this table except inhalants, steroids,'/
' alcohol, cigarettes, or smokeless tobacco.'//
'^L3^KIncludes the use of any drug on this table except inhalants, steroids,'/
' alcohol, cigarettes, smokeless tobacco, or marijuana.'//
'^L4^KRefers only to use not under a doctor''s order.'//
 @36 pageno 2.;
return;
run;

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