BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Calcite | Level 5

## Run the same data step on multiple data set without repeat all the data step

I have a code with a lot of opperation and I want to run it on multiple data set without copying all that multiple times. I try for two days now and found nothing that work.

So here is what is look the more obvious to me (but with the SET all my data merge into one and don't stay independant).

here is the code.

thanks a lot for any help.

data SWS1516n FNAL1516a FNEL1516a FNES1516a FNNA1516a LC1516a;
set SWS1516m FNAL1516 FNEL1516 FNES1516 FNNA1516 LC1516;

%let students6 = Students in grade 6 to 12 who;
%let students7 = Students in grade 7 to 12 who;

/*indicateur Q1 - SH_GRADE*/
if SH_GRADE = 6  then SH_GRADE_1 = 1;
if SH_GRADE = 7  then SH_GRADE_1 = 0;
if SH_GRADE = 8  then SH_GRADE_1 = 0;
if SH_GRADE = 9  then SH_GRADE_1 = 0;
if SH_GRADE = 10 then SH_GRADE_1 = 0;
if SH_GRADE = 11 then SH_GRADE_1 = 0;
if SH_GRADE = 12 then SH_GRADE_1 = 0;
label SH_GRADE_1  = "&students6 are in grade 6";

if SH_GRADE = 6  then SH_GRADE_2 = 0;
if SH_GRADE = 7  then SH_GRADE_2 = 1;
if SH_GRADE = 8  then SH_GRADE_2 = 0;
if SH_GRADE = 9  then SH_GRADE_2 = 0;
if SH_GRADE = 10 then SH_GRADE_2 = 0;
if SH_GRADE = 11 then SH_GRADE_2 = 0;
if SH_GRADE = 12 then SH_GRADE_2 = 0;
label SH_GRADE_2  = "&students6 are in grade 7";

if SH_GRADE = 6  then SH_GRADE_3 = 0;
if SH_GRADE = 7  then SH_GRADE_3 = 0;
if SH_GRADE = 8  then SH_GRADE_3 = 1;
if SH_GRADE = 9  then SH_GRADE_3 = 0;
if SH_GRADE = 10 then SH_GRADE_3 = 0;
if SH_GRADE = 11 then SH_GRADE_3 = 0;
if SH_GRADE = 12 then SH_GRADE_3 = 0;
label SH_GRADE_3  = "&students6 are in grade 8";

if SH_GRADE = 6  then SH_GRADE_4 = 0;
if SH_GRADE = 7  then SH_GRADE_4 = 0;
if SH_GRADE = 8  then SH_GRADE_4 = 0;
if SH_GRADE = 9  then SH_GRADE_4 = 1;
if SH_GRADE = 10 then SH_GRADE_4 = 0;
if SH_GRADE = 11 then SH_GRADE_4 = 0;
if SH_GRADE = 12 then SH_GRADE_4 = 0;
label SH_GRADE_4  = "&students6 are in grade 9";

if SH_GRADE = 6  then SH_GRADE_5 = 0;
if SH_GRADE = 7  then SH_GRADE_5 = 0;
if SH_GRADE = 8  then SH_GRADE_5 = 0;
if SH_GRADE = 9  then SH_GRADE_5 = 0;
if SH_GRADE = 10 then SH_GRADE_5 = 1;
if SH_GRADE = 11 then SH_GRADE_5 = 0;
if SH_GRADE = 12 then SH_GRADE_5 = 0;
label SH_GRADE_5  = "&students6 are in grade 10";

if SH_GRADE = 6  then SH_GRADE_6 = 0;
if SH_GRADE = 7  then SH_GRADE_6 = 0;
if SH_GRADE = 8  then SH_GRADE_6 = 0;
if SH_GRADE = 9  then SH_GRADE_6 = 0;
if SH_GRADE = 10 then SH_GRADE_6 = 0;
if SH_GRADE = 11 then SH_GRADE_6 = 1;
if SH_GRADE = 12 then SH_GRADE_6 = 0;
label SH_GRADE_6  = "&students6 in grade 11";

if SH_GRADE = 6  then SH_GRADE_7 = 0;
if SH_GRADE = 7  then SH_GRADE_7 = 0;
if SH_GRADE = 8  then SH_GRADE_7 = 0;
if SH_GRADE = 9  then SH_GRADE_7 = 0;
if SH_GRADE = 10 then SH_GRADE_7 = 0;
if SH_GRADE = 11 then SH_GRADE_7 = 0;
if SH_GRADE = 12 then SH_GRADE_7 = 1;
label SH_GRADE_7  = "&students6 are in grade 12";

/*indicateur Q2 - SH_AGE01*/
if SH_AGE01 = 10 then SH_AGE01_1 = 1;
if SH_AGE01 = 11 then SH_AGE01_1 = 0;
if SH_AGE01 = 12 then SH_AGE01_1 = 0;
if SH_AGE01 = 13 then SH_AGE01_1 = 0;
if SH_AGE01 = 14 then SH_AGE01_1 = 0;
if SH_AGE01 = 15 then SH_AGE01_1 = 0;
if SH_AGE01 = 16 then SH_AGE01_1 = 0;
if SH_AGE01 = 17 then SH_AGE01_1 = 0;
if SH_AGE01 = 18 then SH_AGE01_1 = 0;
if SH_AGE01 = 19 then SH_AGE01_1 = 0;
label SH_AGE01_1 = "&students6 are 10 years or younger";

if SH_AGE01 = 10 then SH_AGE01_2 = 0;
if SH_AGE01 = 11 then SH_AGE01_2 = 1;
if SH_AGE01 = 12 then SH_AGE01_2 = 0;
if SH_AGE01 = 13 then SH_AGE01_2 = 0;
if SH_AGE01 = 14 then SH_AGE01_2 = 0;
if SH_AGE01 = 15 then SH_AGE01_2 = 0;
if SH_AGE01 = 16 then SH_AGE01_2 = 0;
if SH_AGE01 = 17 then SH_AGE01_2 = 0;
if SH_AGE01 = 18 then SH_AGE01_2 = 0;
if SH_AGE01 = 19 then SH_AGE01_2 = 0;
label SH_AGE01_2 = "&students6 are 11 years old";

if SH_AGE01 = 10 then SH_AGE01_3 = 0;
if SH_AGE01 = 11 then SH_AGE01_3 = 0;
if SH_AGE01 = 12 then SH_AGE01_3 = 1;
if SH_AGE01 = 13 then SH_AGE01_3 = 0;
if SH_AGE01 = 14 then SH_AGE01_3 = 0;
if SH_AGE01 = 15 then SH_AGE01_3 = 0;
if SH_AGE01 = 16 then SH_AGE01_3 = 0;
if SH_AGE01 = 17 then SH_AGE01_3 = 0;
if SH_AGE01 = 18 then SH_AGE01_3 = 0;
if SH_AGE01 = 19 then SH_AGE01_3 = 0;
label SH_AGE01_3 = "&students6 are 12 years old";

if SH_AGE01 = 10 then SH_AGE01_4 = 0;
if SH_AGE01 = 11 then SH_AGE01_4 = 0;
if SH_AGE01 = 12 then SH_AGE01_4 = 0;
if SH_AGE01 = 13 then SH_AGE01_4 = 1;
if SH_AGE01 = 14 then SH_AGE01_4 = 0;
if SH_AGE01 = 15 then SH_AGE01_4 = 0;
if SH_AGE01 = 16 then SH_AGE01_4 = 0;
if SH_AGE01 = 17 then SH_AGE01_4 = 0;
if SH_AGE01 = 18 then SH_AGE01_4 = 0;
if SH_AGE01 = 19 then SH_AGE01_4 = 0;
label SH_AGE01_4 = "&students6 are 13 years old";

if SH_AGE01 = 10 then SH_AGE01_5 = 0;
if SH_AGE01 = 11 then SH_AGE01_5 = 0;
if SH_AGE01 = 12 then SH_AGE01_5 = 0;
if SH_AGE01 = 13 then SH_AGE01_5 = 0;
if SH_AGE01 = 14 then SH_AGE01_5 = 1;
if SH_AGE01 = 15 then SH_AGE01_5 = 0;
if SH_AGE01 = 16 then SH_AGE01_5 = 0;
if SH_AGE01 = 17 then SH_AGE01_5 = 0;
if SH_AGE01 = 18 then SH_AGE01_5 = 0;
if SH_AGE01 = 19 then SH_AGE01_5 = 0;
label SH_AGE01_5 = "&students6 are 14 years old";

if SH_AGE01 = 10 then SH_AGE01_6 = 0;
if SH_AGE01 = 11 then SH_AGE01_6 = 0;
if SH_AGE01 = 12 then SH_AGE01_6 = 0;
if SH_AGE01 = 13 then SH_AGE01_6 = 0;
if SH_AGE01 = 14 then SH_AGE01_6 = 0;
if SH_AGE01 = 15 then SH_AGE01_6 = 1;
if SH_AGE01 = 16 then SH_AGE01_6 = 0;
if SH_AGE01 = 17 then SH_AGE01_6 = 0;
if SH_AGE01 = 18 then SH_AGE01_6 = 0;
if SH_AGE01 = 19 then SH_AGE01_6 = 0;
label SH_AGE01_6 = "&students6 are 15 years old";

if SH_AGE01 = 10 then SH_AGE01_7 = 0;
if SH_AGE01 = 11 then SH_AGE01_7 = 0;
if SH_AGE01 = 12 then SH_AGE01_7 = 0;
if SH_AGE01 = 13 then SH_AGE01_7 = 0;
if SH_AGE01 = 14 then SH_AGE01_7 = 0;
if SH_AGE01 = 15 then SH_AGE01_7 = 0;
if SH_AGE01 = 16 then SH_AGE01_7 = 1;
if SH_AGE01 = 17 then SH_AGE01_7 = 0;
if SH_AGE01 = 18 then SH_AGE01_7 = 0;
if SH_AGE01 = 19 then SH_AGE01_7 = 0;
label SH_AGE01_7 = "&students6 are 16 years old";

if SH_AGE01 = 10 then SH_AGE01_8 = 0;
if SH_AGE01 = 11 then SH_AGE01_8 = 0;
if SH_AGE01 = 12 then SH_AGE01_8 = 0;
if SH_AGE01 = 13 then SH_AGE01_8 = 0;
if SH_AGE01 = 14 then SH_AGE01_8 = 0;
if SH_AGE01 = 15 then SH_AGE01_8 = 0;
if SH_AGE01 = 16 then SH_AGE01_8 = 0;
if SH_AGE01 = 17 then SH_AGE01_8 = 1;
if SH_AGE01 = 18 then SH_AGE01_8 = 0;
if SH_AGE01 = 19 then SH_AGE01_8 = 0;
label SH_AGE01_8 = "&students6 are 17 years old";

if SH_AGE01 = 10 then SH_AGE01_9 = 0;
if SH_AGE01 = 11 then SH_AGE01_9 = 0;
if SH_AGE01 = 12 then SH_AGE01_9 = 0;
if SH_AGE01 = 13 then SH_AGE01_9 = 0;
if SH_AGE01 = 14 then SH_AGE01_9 = 0;
if SH_AGE01 = 15 then SH_AGE01_9 = 0;
if SH_AGE01 = 16 then SH_AGE01_9 = 0;
if SH_AGE01 = 17 then SH_AGE01_9 = 0;
if SH_AGE01 = 18 then SH_AGE01_9 = 1;
if SH_AGE01 = 19 then SH_AGE01_9 = 0;
label SH_AGE01_9 = "&students6 are 18 years old";

if SH_AGE01 = 10 then SH_AGE01_10 = 0;
if SH_AGE01 = 11 then SH_AGE01_10 = 0;
if SH_AGE01 = 12 then SH_AGE01_10 = 0;
if SH_AGE01 = 13 then SH_AGE01_10 = 0;
if SH_AGE01 = 14 then SH_AGE01_10 = 0;
if SH_AGE01 = 15 then SH_AGE01_10 = 0;
if SH_AGE01 = 16 then SH_AGE01_10 = 0;
if SH_AGE01 = 17 then SH_AGE01_10 = 0;
if SH_AGE01 = 18 then SH_AGE01_10 = 0;
if SH_AGE01 = 19 then SH_AGE01_10 = 1;
label SH_AGE01_10 = "&students6 are 19 years or older";

/*indicateur Q3 - SH_GEN01*/
if SH_GEN01 = 1 then SH_GEN01_1 = 1;
if SH_GEN01 = 2 then SH_GEN01_1 = 0;
if SH_GEN01 = 3 then SH_GEN01_1 = 0;
label SH_GEN01_1 = "&students6 identify themselves as female";

if SH_GEN01 = 1 then SH_GEN01_2 = 0;
if SH_GEN01 = 2 then SH_GEN01_2 = 1;
if SH_GEN01 = 3 then SH_GEN01_2 = 0;
label SH_GEN01_2 = "&students6 identify themselves as male";

if SH_GEN01 = 1 then SH_GEN01_3 = 0;
if SH_GEN01 = 2 then SH_GEN01_3 = 0;
if SH_GEN01 = 3 then SH_GEN01_3 = 1;
label SH_GEN01_3 = "&students6 identify themselves as gendre independent";

/*indicateur Q4 - SH_LAN01*/
if SH_LAN01 = 1 then SH_LAN01_1 = 1;
if SH_LAN01 = 2 then SH_LAN01_1 = 0;
if SH_LAN01 = 3 then SH_LAN01_1 = 0;
if SH_LAN01 = 4 then SH_LAN01_1 = 0;
label SH_LAN01_1 = "&students6 report most often speaking English at home";

if SH_LAN01 = 1 then SH_LAN01_2 = 0;
if SH_LAN01 = 2 then SH_LAN01_2 = 1;
if SH_LAN01 = 3 then SH_LAN01_2 = 0;
if SH_LAN01 = 4 then SH_LAN01_2 = 0;
label SH_LAN01_2 = "&students6 report most often speaking French at home";

if SH_LAN01 = 1 then SH_LAN01_3 = 0;
if SH_LAN01 = 2 then SH_LAN01_3 = 0;
if SH_LAN01 = 3 then SH_LAN01_3 = 1;
if SH_LAN01 = 4 then SH_LAN01_3 = 0;
label SH_LAN01_3 = "&students6 report most often speaking an indigenous language at home";

if SH_LAN01 = 1 then SH_LAN01_4 = 0;
if SH_LAN01 = 2 then SH_LAN01_4 = 0;
if SH_LAN01 = 3 then SH_LAN01_4 = 0;
if SH_LAN01 = 4 then SH_LAN01_4 = 1;
label SH_LAN01_4 = "&students6 report most often speaking another language (other than English, French or an indigenous language) at home";

/*indicateur Q5 - SH_LAN02*/
if SH_LAN02 = 1 then SH_LAN02_1 = 1;
if SH_LAN02 = 2 then SH_LAN02_1 = 0;
if SH_LAN02 = 3 then SH_LAN02_1 = 0;
if SH_LAN02 = 4 then SH_LAN02_1 = 0;
label SH_LAN02_1 = "&students6 report most often speaking English when not at home or in school";

if SH_LAN02 = 1 then SH_LAN02_2 = 0;
if SH_LAN02 = 2 then SH_LAN02_2 = 1;
if SH_LAN02 = 3 then SH_LAN02_2 = 0;
if SH_LAN02 = 4 then SH_LAN02_2 = 0;
label SH_LAN02_2 = "&students6 report most often speaking French when not at home or in school";

if SH_LAN02 = 1 then SH_LAN02_3 = 0;
if SH_LAN02 = 2 then SH_LAN02_3 = 0;
if SH_LAN02 = 3 then SH_LAN02_3 = 1;
if SH_LAN02 = 4 then SH_LAN02_3 = 0;
label SH_LAN02_3 = "&students6 report most often speaking an indigenous language when not at home or in school";

if SH_LAN02 = 1 then SH_LAN02_4 = 0;
if SH_LAN02 = 2 then SH_LAN02_4 = 0;
if SH_LAN02 = 3 then SH_LAN02_4 = 0;
if SH_LAN02 = 4 then SH_LAN02_4 = 1;
label SH_LAN02_4 = "&students6 report most often speaking another language (other than English, French or an indigenous language) when not at home or in school";

/*indicateur Q6 - all that apply*/
if SH_ETHWH = 1 then SH_ETHWH_1 = 1;
if SH_ETHWH = 0 then SH_ETHWH_1 = 0;
label SH_ETHWH_1 = "&students6 identify themselves as coming from a white cultural and racial background";

if SH_ETHBL = 1 then SH_ETHBL_1 = 1;
if SH_ETHBL = 0 then SH_ETHBL_1 = 0;
label SH_ETHBL_1 = "&students6 identify themselves as coming from a black cultural and racial background";

SH_ABO01_1 = SH_ABO01;
label SH_ABO01_1 = "&students6 identify themselves as coming from an Aboriginal cultural and racial background";

if (SH_ETHKO = 1) or
(SH_ETHCH = 1) or
(SH_ETHJA = 1) or
(SH_ETHAS = 1) or
(SH_ETHFI = 1) then SH_ASI01_1 = 1;
else SH_ASI01_1 = 0;
label SH_ASI01_1 = "&students6 identify themselves as coming from an Asian cultural and racial background";

if (SH_ETHLA = 1) or
(SH_ETHAR = 1) or
(SH_ETHOT = 1) then SH_LAT01_1 = 1;
else SH_LAT01_1 = 0;
label SH_LAT01_1 = "&students6 identify themselves as coming from a cultural and racial background other than white, black, Aboriginal or Asian";

/*indicateur Q7 - SH_IMM02*/
SH_IMM03_1 = SH_IMM03;
label SH_IMM03_1 = "&students6 lived in Canada for 10 years or less'";

/*indicateur Q9 - SH_HEP01*/
if  SH_HEP01 = 1 then SH_HEP01_1 = 0;
if  SH_HEP01 = 2 then SH_HEP01_1 = 0;
if  SH_HEP01 = 3 then SH_HEP01_1 = 0;
if  SH_HEP01 = 4 then SH_HEP01_1 = 1;
if  SH_HEP01 = 5 then SH_HEP01_1 = 1;
label SH_HEP01_1 = "&students6 report their helath is Very good or Excellent";

/*indicateur Q10 - SH_LIF01*/
SH_LIF01_1 = 0;
if SH_LIF01 <= 5 then SH_LIF01_1 = 1;
if SH_LIF01 >  5 then SH_LIF01_1 = 0;
if SH_LIF01 = .  then SH_LIF01_1 = .;
label SH_LIF01_1 = "&students6 self reported a life satisfaction score of 0-5";

SH_LIF01_2 = 0;
if SH_LIF01 = 6 then SH_LIF01_2 = 1;
if SH_LIF01 = 7 then SH_LIF01_2 = 1;
if SH_LIF01 = . then SH_LIF01_2 = .;
label SH_LIF01_2 = "&students6 self reported a life satisfaction score of 6-7";

SH_LIF01_3 = 0;
if SH_LIF01 = 8 then SH_LIF01_3 = 1;
if SH_LIF01 = 9 then SH_LIF01_3 = 1;
if SH_LIF01 = . then SH_LIF01_3 = .;
label SH_LIF01_3 = "&students6 self reported a life satisfaction score of 8-9";

SH_LIF01_4 = 0;
if SH_LIF01 = 8  then SH_LIF01_4 = 1;
if SH_LIF01 = 9  then SH_LIF01_4 = 1;
if SH_LIF01 = 10 then SH_LIF01_4 = 1;
if SH_LIF01 = .  then SH_LIF01_4 = .;
label SH_LIF01_4 = "&students6 self reported a life satisfaction score of 8-10";

SH_LIF01_5 = 0;
if SH_LIF01 = 10 then SH_LIF01_5 = 1;
if SH_LIF01 = .  then SH_LIF01_5 = .;
label SH_LIF01_5 = "&students6 self reported a life satisfaction score of 10";

SH_LIF01_6 = SH_LIF01;
label SH_LIF01_6 = "Average life satisfaction score of students in grades 6 to 12";

/*indicateur Q11 et Q12 - SH_BMI02*/
if SH_BMI02 = 1 then SH_BMI02_1 = 0;
if SH_BMI02 = 2 then SH_BMI02_1 = 1;
if SH_BMI02 = 3 then SH_BMI02_1 = 0;
if SH_BMI02 = 4 then SH_BMI02_1 = 0;
label SH_BMI02_1 = "&students6 are considered to be of healthy weight, based on self-reported height and weight";

if SH_BMI02 = 1 then SH_BMI02_2 = 1;
if SH_BMI02 = 2 then SH_BMI02_2 = 0;
if SH_BMI02 = 3 then SH_BMI02_2 = 0;
if SH_BMI02 = 4 then SH_BMI02_2 = 0;
label SH_BMI02_2 = "&students6 are considered to be underweight, based on self-reported height and weight";

if SH_BMI02 = 1 then SH_BMI02_3 = 0;
if SH_BMI02 = 2 then SH_BMI02_3 = 0;
if SH_BMI02 = 3 then SH_BMI02_3 = 1;
if SH_BMI02 = 4 then SH_BMI02_3 = 1;
label SH_BMI02_3 = "&students6 are considered to be overweight or obese, based on self-reported height and weight";

if (SH_BMI02 = .) or (SH_GEN01 ne 2) then SH_BMI02_4 = .;
else if SH_BMI02 = 1 then SH_BMI02_4 = 0;
else if SH_BMI02 = 2 then SH_BMI02_4 = 0;
else if SH_BMI02 = 3 then SH_BMI02_4 = 1;
else if SH_BMI02 = 4 then SH_BMI02_4 = 1;
label SH_BMI02_4 = "Male students in grades 6 to 12 who are considered to be overweight or obese, based on self-reported height and weight";

if (SH_BMI02 = .) or (SH_GEN01 ne 1) then SH_BMI02_5 = .;
else if SH_BMI02 = 1 then SH_BMI02_5 = 0;
else if SH_BMI02 = 2 then SH_BMI02_5 = 0;
else if SH_BMI02 = 3 then SH_BMI02_5 = 1;
else if SH_BMI02 = 4 then SH_BMI02_5 = 1;
label SH_BMI02_5 = "Female students in grades 6 to 12 who are considered to be overweight or obese, based on self-reported height and weight";

/*indicateur Q13 - all that apply*/
if SH_SENAU = 1 then SH_SENAU_1 = 1;
if SH_SENAU = 0 then SH_SENAU_1 = 0;
label SH_SENAU_1 = "&students6 have been diagnosed with Autism/Asperger Syndrome";

if SH_SENBE = 1 then SH_SENBE_1 = 1;
if SH_SENBE = 0 then SH_SENBE_1 = 0;
label SH_SENBE_1 = "&students6 have been diagnosed with a behavioural disorder";

if SH_SENBL = 1 then SH_SENBL_1 = 1;
if SH_SENBL = 0 then SH_SENBL_1 = 0;
label SH_SENBL_1 = "&students6 have been diagnosed blind or with low vision";

if SH_SENDE = 1 then SH_SENDE_1 = 1;
if SH_SENDE = 0 then SH_SENDE_1 = 0;
label SH_SENDE_1 = "&students6 have been diagnosed deaf or hard-of-hearing";

if SH_SENAT = 1 then SH_SENAT_1 = 1;
if SH_SENAT = 0 then SH_SENAT_1 = 0;
label SH_SENAT_1 = "&students6 have been diagnosed with an Attention Deficit Hyperactivity Disorder (ADHD) or an Attention Deficit Disorder (ADD)";

if SH_SENIN = 1 then SH_SENIN_1 = 1;
if SH_SENIN = 0 then SH_SENIN_1 = 0;
label SH_SENIN_1 = "&students6 have been diagnosed with an intellectual disability";

if SH_SENLA = 1 then SH_SENLA_1 = 1;
if SH_SENLA = 0 then SH_SENLA_1 = 0;
label SH_SENLA_1 = "&students6 have been diagnosed with a language / speech impairment";

if SH_SENLE = 1 then SH_SENLE_1 = 1;
if SH_SENLE = 0 then SH_SENlE_1 = 0;
label SH_SENLE_1 = "&students6 have been diagnosed with a learning disability";

if SH_SENPH = 1 then SH_SENPH_1 = 1;
if SH_SENPH = 0 then SH_SENPH_1 = 0;
label SH_SENPH_1 = "&students6 have been diagnosed with a physical disability";

if SH_SENME = 1 then SH_SENME_1 = 1;
if SH_SENME = 0 then SH_SENME_1 = 0;
label SH_SENME_1 = "&students6 have been diagnosed with a mental health disability";

if SH_SENGI = 1 then SH_SENGI_1 = 1;
if SH_SENGI = 0 then SH_SENGI_1 = 0;
label SH_SENGI_1 = "&students6 have been diagnosed gifted";

if SH_SENOT = 1 then SH_SENOT_1 = 1;
if SH_SENOT = 0 then SH_SENOT_1 = 0;
label SH_SENOT_1 = "&students6 have been diagnosed with another learning execptionality or special education need";

SH_SENAL_1 = SH_SENAL;
label SH_SENAL_1 = "&students6 have been diagnosed with a learning exceptionality or special education need";

/*indicateur Q14A - SH_DAA01*/
if SH_DAA01 = 1 then SH_DAA01_1 = 0;
if SH_DAA01 = 2 then SH_DAA01_1 = 0;
if SH_DAA01 = 3 then SH_DAA01_1 = 0;
if SH_DAA01 = 4 then SH_DAA01_1 = 1;
if SH_DAA01 = 5 then SH_DAA01_1 = 1;
label SH_DAA01_1 = "&students6, on average, spends more than 2 hours a day on screen time";

/*indicateur Q14B - SH_DAA02*/
if SH_DAA02 = 1 then SH_DAA02_1 = 1;
if SH_DAA02 = 2 then SH_DAA02_1 = 0;
if SH_DAA02 = 3 then SH_DAA02_1 = 0;
if SH_DAA02 = 4 then SH_DAA02_1 = 0;
if SH_DAA02 = 5 then SH_DAA02_1 = 0;
label SH_DAA02_1 = "&students6, on average, spend no time doing homework in a day";

if SH_DAA02 = 1 then SH_DAA02_2 = 0;
if SH_DAA02 = 2 then SH_DAA02_2 = 1;
if SH_DAA02 = 3 then SH_DAA02_2 = 0;
if SH_DAA02 = 4 then SH_DAA02_2 = 0;
if SH_DAA02 = 5 then SH_DAA02_2 = 0;
label SH_DAA02_2 = "&students6, on average, spend less than one hour a day doing homework";

if SH_DAA02 = 1 then SH_DAA02_3 = 0;
if SH_DAA02 = 2 then SH_DAA02_3 = 0;
if SH_DAA02 = 3 then SH_DAA02_3 = 1;
if SH_DAA02 = 4 then SH_DAA02_3 = 0;
if SH_DAA02 = 5 then SH_DAA02_3 = 0;
label SH_DAA02_3 = "&students6, on average, spend 1 to 2 hours a day doing homework";

if SH_DAA02 = 1 then SH_DAA02_4 = 0;
if SH_DAA02 = 2 then SH_DAA02_4 = 0;
if SH_DAA02 = 3 then SH_DAA02_4 = 0;
if SH_DAA02 = 4 then SH_DAA02_4 = 1;
if SH_DAA02 = 5 then SH_DAA02_4 = 0;
label SH_DAA02_4 = "&students6, on average, spend more than 2 but less than 5 hours a day doing homework";

if SH_DAA02 = 1 then SH_DAA02_5 = 0;
if SH_DAA02 = 2 then SH_DAA02_5 = 0;
if SH_DAA02 = 3 then SH_DAA02_5 = 0;
if SH_DAA02 = 4 then SH_DAA02_5 = 0;
if SH_DAA02 = 5 then SH_DAA02_5 = 1;
label SH_DAA02_5 = "&students6, on average, spend 5 or more hours a day doing homework";

/*indicateur Q14C - SH_DAA03*/
if SH_DAA03 = 1 then SH_DAA03_1 = 1;
if SH_DAA03 = 2 then SH_DAA03_1 = 0;
if SH_DAA03 = 3 then SH_DAA03_1 = 0;
if SH_DAA03 = 4 then SH_DAA03_1 = 0;
if SH_DAA03 = 5 then SH_DAA03_1 = 0;
label SH_DAA03_1 = "&students6, on average, spend no time reading for fun in a day";

if SH_DAA03 = 1 then SH_DAA03_2 = 0;
if SH_DAA03 = 2 then SH_DAA03_2 = 1;
if SH_DAA03 = 3 then SH_DAA03_2 = 0;
if SH_DAA03 = 4 then SH_DAA03_2 = 0;
if SH_DAA03 = 5 then SH_DAA03_2 = 0;
label SH_DAA03_2 = "&students6, on average, spend less than one hour a day reading for fun";

if SH_DAA03 = 1 then SH_DAA03_3 = 0;
if SH_DAA03 = 2 then SH_DAA03_3 = 0;
if SH_DAA03 = 3 then SH_DAA03_3 = 1;
if SH_DAA03 = 4 then SH_DAA03_3 = 0;
if SH_DAA03 = 5 then SH_DAA03_3 = 0;
label SH_DAA03_3 = "&students6, on average, spend 1 to 2 hours a day reading for fun";

if SH_DAA03 = 1 then SH_DAA03_4 = 0;
if SH_DAA03 = 2 then SH_DAA03_4 = 0;
if SH_DAA03 = 3 then SH_DAA03_4 = 0;
if SH_DAA03 = 4 then SH_DAA03_4 = 1;
if SH_DAA03 = 5 then SH_DAA03_4 = 0;
label SH_DAA03_4 = "&students6, on average, spend more than 2 but less than 5 hours a day reading for fun";

if SH_DAA03 = 1 then SH_DAA03_5 = 0;
if SH_DAA03 = 2 then SH_DAA03_5 = 0;
if SH_DAA03 = 3 then SH_DAA03_5 = 0;
if SH_DAA03 = 4 then SH_DAA03_5 = 0;
if SH_DAA03 = 5 then SH_DAA03_5 = 1;
label SH_DAA03_5 = "&students6, on average, spend 5 or more hours a day reading for fun";

/*indicateur Q15 - SH_PHY01*/
if SH_PHY01 = 7 then SH_PHY01_1 = 1;
else if SH_PHY01 = . then SH_PHY01_1 = .;
else SH_PHY01_1 = 0;
label SH_PHY01_1 = "&students6 report having been physically active for at least 60 minutes per day over the past 7 days";

/*indicateur Q16 - SH_PHY02*/
if SH_PHY02 = 1 then SH_PHY02_1 = 1;
if SH_PHY02 = 2 then SH_PHY02_1 = 0;
if SH_PHY02 = 3 then SH_PHY02_1 = 0;
label SH_PHY02_1 = "&students6 report usually getting to and from school actively (e.g., walk, bike, skateboard)";

if SH_PHY02 = 1 then SH_PHY02_2 = 0;
if SH_PHY02 = 2 then SH_PHY02_2 = 1;
if SH_PHY02 = 3 then SH_PHY02_2 = 0;
label SH_PHY02_2 = "&students6 report usually getting to and from school inactively (e.g., car, bus, public transit)";

if SH_PHY02 = 1 then SH_PHY02_3 = 0;
if SH_PHY02 = 2 then SH_PHY02_3 = 0;
if SH_PHY02 = 3 then SH_PHY02_3 = 1;
label SH_PHY02_3 = "&students6 report usually getting to and from school both actively (e.g., walk, bike, skateboard) and inactively (e.g., car, bus, public transit)";

/*indicateur Q17 - SH_PHY03*/
if SH_PHY03 = 0 then SH_PHY03_1 = 1;
if SH_PHY03 = 1 then SH_PHY03_1 = 0;
if SH_PHY03 = 2 then SH_PHY03_1 = 0;
if SH_PHY03 = 3 then SH_PHY03_1 = 0;
if SH_PHY03 = 4 then SH_PHY03_1 = 0;
if SH_PHY03 = 5 then SH_PHY03_1 = 0;
label SH_PHY03_1 = "&students6 report having zero Physical Education class at school in the last five school days";

if SH_PHY03 = 0 then SH_PHY03_2 = 0;
if SH_PHY03 = 1 then SH_PHY03_2 = 1;
if SH_PHY03 = 2 then SH_PHY03_2 = 0;
if SH_PHY03 = 3 then SH_PHY03_2 = 0;
if SH_PHY03 = 4 then SH_PHY03_2 = 0;
if SH_PHY03 = 5 then SH_PHY03_2 = 0;
label SH_PHY03_2 = "&students6 report having one Physical Education class at school in the last five school days";

if SH_PHY03 = 0 then SH_PHY03_3 = 0;
if SH_PHY03 = 1 then SH_PHY03_3 = 0;
if SH_PHY03 = 2 then SH_PHY03_3 = 1;
if SH_PHY03 = 3 then SH_PHY03_3 = 0;
if SH_PHY03 = 4 then SH_PHY03_3 = 0;
if SH_PHY03 = 5 then SH_PHY03_3 = 0;
label SH_PHY03_3 = "&students6 report having two Physical Education classes at school in the last five school days";

if SH_PHY03 = 0 then SH_PHY03_4 = 0;
if SH_PHY03 = 1 then SH_PHY03_4 = 0;
if SH_PHY03 = 2 then SH_PHY03_4 = 0;
if SH_PHY03 = 3 then SH_PHY03_4 = 1;
if SH_PHY03 = 4 then SH_PHY03_4 = 0;
if SH_PHY03 = 5 then SH_PHY03_4 = 0;
label SH_PHY03_4 = "&students6 report having three Physical Education classes at school in the last five school days";

if SH_PHY03 = 0 then SH_PHY03_5 = 0;
if SH_PHY03 = 1 then SH_PHY03_5 = 0;
if SH_PHY03 = 2 then SH_PHY03_5 = 0;
if SH_PHY03 = 3 then SH_PHY03_5 = 0;
if SH_PHY03 = 4 then SH_PHY03_5 = 1;
if SH_PHY03 = 5 then SH_PHY03_5 = 0;
label SH_PHY03_5 = "&students6 report having four Physical Education classes at school in the last five school days";

if SH_PHY03 = 0 then SH_PHY03_6 = 0;
if SH_PHY03 = 1 then SH_PHY03_6 = 0;
if SH_PHY03 = 2 then SH_PHY03_6 = 0;
if SH_PHY03 = 3 then SH_PHY03_6 = 0;
if SH_PHY03 = 4 then SH_PHY03_6 = 0;
if SH_PHY03 = 5 then SH_PHY03_6 = 1;
label SH_PHY03_6 = "&students6 report having five Physical Education classes at school in the last five school days";

/*indicateur Q18 - SH_PHY04*/
if SH_PHY04 = 1 then SH_PHY04_1 = 1;
if SH_PHY04 = 0 then SH_PHY04_1 = 0;
if SH_PHY04 = 3 then SH_PHY04_1 = 0;
label SH_PHY04_1 = "&students6 report participating in before school, noon hour, or after school physical activities organized by their school";

if SH_PHY04 = 1 then SH_PHY04_2 = 0;
if SH_PHY04 = 0 then SH_PHY04_2 = 1;
if SH_PHY04 = 3 then SH_PHY04_2 = 0;
label SH_PHY04_2 = "&students6 report not participating in before school, noon hour, or after school physical activities organized by their school";

if SH_PHY04 = 1 then SH_PHY04_3 = 0;
if SH_PHY04 = 0 then SH_PHY04_3 = 0;
if SH_PHY04 = 3 then SH_PHY04_3 = 1;
label SH_PHY04_3 = "&students6 report not participating in before school, noon hour, or after school physical activities organized by their school: none offered";

/*indicateur Q19 - SH_PHY05*/
if SH_PHY05 = 1 then SH_PHY05_1 = 1;
if SH_PHY05 = 0 then SH_PHY05_1 = 0;
if SH_PHY05 = 3 then SH_PHY05_1 = 0;
label SH_PHY05_1 = "&students6 report participating in competitive school sports teams that compete against other schools";

if SH_PHY05 = 1 then SH_PHY05_2 = 0;
if SH_PHY05 = 0 then SH_PHY05_2 = 1;
if SH_PHY05 = 3 then SH_PHY05_2 = 0;
label SH_PHY05_2 = "&students6 report not participating in competitive school sports teams that compete against other schools";

if SH_PHY05 = 1 then SH_PHY05_3 = 0;
if SH_PHY05 = 0 then SH_PHY05_3 = 0;
if SH_PHY05 = 3 then SH_PHY05_3 = 1;
label SH_PHY05_3 = "&students6 report not participating in competitive school sports teams that compete against other schools: none offered";

/*indicateur Q20 - all that apply*/
if SH_INSST = 1 then SH_INSST_1 = 1;
if SH_INSST = 0 then SH_INSST_1 = 0;
label SH_INSST_1 = "&students6 report being involved in a sports team inside school";

if SH_INSIS = 1 then SH_INSIS_1 = 1;
if SH_INSIS = 0 then SH_INSIS_1 = 0;
label SH_INSIS_1 = "&students6 report being involved in an individual sport inside school";

if SH_INSVW = 1 then SH_INSVW_1 = 1;
if SH_INSVW = 0 then SH_INSVW_1 = 0;
label SH_INSVW_1 = "&students6 report being involved in volunteer work inside school";

if SH_INSAG = 1 then SH_INSAG_1 = 1;
if SH_INSAG = 0 then SH_INSAG_1 = 0;
label SH_INSAG_1 = "&students6 report being involved in arts groups inside school";

if SH_INSSC = 1 then SH_INSSC_1 = 1;
if SH_INSSC = 0 then SH_INSSC_1 = 0;
label SH_INSSC_1 = "&students6 report being involved in student clubs or groups inside school";

if SH_INSSE = 1 then SH_INSSE_1 = 1;
if SH_INSSE = 0 then SH_INSSE_1 = 0;
label SH_INSSE_1 = "&students6 report being involved in science or technology inside school";

if SH_INSCH = 1 then SH_INSCH_1 = 1;
if SH_INSCH = 0 then SH_INSCH_1 = 0;
label SH_INSCH_1 = "&students6 report being involved in church or other religious/spiritual group inside school";

if SH_INSOT = 1 then SH_INSOT_1 = 1;
if SH_INSOT = 0 then SH_INSOT_1 = 0;
label SH_INSOT_1 = "&students6 report being involved in any other activity or group inside school";

if (SH_INSST = 1) or
(SH_INSIS = 1) or
(SH_INSVW = 1) or
(SH_INSAG = 1) or
(SH_INSSC = 1) or
(SH_INSST = 1) or
(SH_INSCH = 1) or
(SH_INSOT = 1) then SH_INSAL_1 = 1;
else SH_INSAL_1 = 0;
label SH_INSAL_1 = "&students6 report being involved in any activities or groups inside school";

/*indicateur Q21 - all that apply*/
if SH_OUSST = 1 then SH_OUSST_1 = 1;
if SH_OUSST = 0 then SH_OUSST_1 = 0;
label SH_OUSST_1 = "&students6 report being involved in a sports team outside school";

if SH_OUSIS = 1 then SH_OUSIS_1 = 1;
if SH_OUSIS = 0 then SH_OUSIS_1 = 0;
label SH_OUSIS_1 = "&students6 report being involved in an individual sport outside school";

if SH_OUSVW = 1 then SH_OUSVW_1 = 1;
if SH_OUSVW = 0 then SH_OUSVW_1 = 0;
label SH_OUSVW_1 = "&students6 report being involved in volunteer work outside school";

if SH_OUSAG = 1 then SH_OUSAG_1 = 1;
if SH_OUSAG = 0 then SH_OUSAG_1 = 0;
label SH_OUSAG_1 = "&students6 report being involved in arts groups outside school ";

if SH_OUSCG = 1 then SH_OUSCG_1 = 1;
if SH_OUSCG = 0 then SH_OUSCG_1 = 0;
label SH_OUSCG_1 = "&students6 report being involved in community groups outside school";

if SH_OUSCH = 1 then SH_OUSCH_1 = 1;
if SH_OUSCH = 0 then SH_OUSCH_1 = 0;
label SH_OUSCH_1 = "&students6 report being involved in church or other religious/spiritual group outside school";

if SH_OUSOT = 1 then SH_OUSOT_1 = 1;
if SH_OUSOT = 0 then SH_OUSOT_1 = 0;
label SH_OUSOT_1 = "&students6 report being involved in any other activity or group outside school";

if (SH_OUSST = 1) or
(SH_OUSIS = 1) or
(SH_OUSVW = 1) or
(SH_OUSAG = 1) or
(SH_OUSCG = 1) or
(SH_OUSCH = 1) or
(SH_OUSOT = 1) then SH_OUSAL_1 = 1;
else SH_OUSAL_1 = 0;
label SH_OUSAL_1 = "&students6 report being involved in any activities or groups outside school";

/*indicateur Q22 - SH_SCC01_1 SH_SCC02_1 SH_SCC03_1 SH_SCC04_1 SH_SCC05_1 SH_SCC06_1*/
if SH_SCC01 = 1 then SH_SCC01_1 = 0;
if SH_SCC01 = 2 then SH_SCC01_1 = 0;
if SH_SCC01 = 3 then SH_SCC01_1 = 1;
if SH_SCC01 = 4 then SH_SCC01_1 = 1;
label SH_SCC01_1 = "&students6 strongly agree or agree they feel close to people at their school";

if SH_SCC02 = 1 then SH_SCC02_1 = 0;
if SH_SCC02 = 2 then SH_SCC02_1 = 0;
if SH_SCC02 = 3 then SH_SCC02_1 = 1;
if SH_SCC02 = 4 then SH_SCC02_1 = 1;
label SH_SCC02_1 = "&students6 strongly agree or agree they feel they are part of their school";

if SH_SCC03 = 1 then SH_SCC03_1 = 0;
if SH_SCC03 = 2 then SH_SCC03_1 = 0;
if SH_SCC03 = 3 then SH_SCC03_1 = 1;
if SH_SCC03 = 4 then SH_SCC03_1 = 1;
label SH_SCC03_1 = "&students6 strongly agree or agree they are happy to be at their school";

if SH_SCC04 = 1 then SH_SCC04_1 = 0;
if SH_SCC04 = 2 then SH_SCC04_1 = 0;
if SH_SCC04 = 3 then SH_SCC04_1 = 1;
if SH_SCC04 = 4 then SH_SCC04_1 = 1;
label SH_SCC04_1 = "&students6 strongly agree or agree they feel the teachers at their school treat them fairly";

if SH_SCC05 = 1 then SH_SCC05_1 = 0;
if SH_SCC05 = 2 then SH_SCC05_1 = 0;
if SH_SCC05 = 3 then SH_SCC05_1 = 1;
if SH_SCC05 = 4 then SH_SCC05_1 = 1;
label SH_SCC05_1 = "&students6 strongly agree or agree they feel safe in their school";

if SH_SCC06 = 1 then SH_SCC06_1 = 0;
if SH_SCC06 = 2 then SH_SCC06_1 = 0;
if SH_SCC06 = 3 then SH_SCC06_1 = 1;
if SH_SCC06 = 4 then SH_SCC06_1 = 1;
label SH_SCC06_1 = "&students6 strongly agree or agree that their learning needs are met at their school";

/*compte le nombre de missing pour les variables SH_SCC01-SH_SCC05 et creation dune nouvelle variable avec le nombre de miss (SCCMISS)*/
array SCC(5) SH_SCC01-SH_SCC05;
SCCMISS = cmiss(of SCC [*]);

/*creation d'une variable temporaire*/
SH_SCC001 = SH_SCC01;
SH_SCC002 = SH_SCC02;
SH_SCC003 = SH_SCC03;
SH_SCC004 = SH_SCC04;
SH_SCC005 = SH_SCC05;

/*remplacement des donnees manquantes (si moins que 6 manquantes) par la moyenne du sujet au score total*/
if (SH_SCC001 = .) and (SCCMISS <= 2) then SH_SCC001 = mean(of SH_SCC001-SH_SCC005);
if (SH_SCC002 = .) and (SCCMISS <= 2) then SH_SCC002 = mean(of SH_SCC001-SH_SCC005);
if (SH_SCC003 = .) and (SCCMISS <= 2) then SH_SCC003 = mean(of SH_SCC001-SH_SCC005);
if (SH_SCC004 = .) and (SCCMISS <= 2) then SH_SCC004 = mean(of SH_SCC001-SH_SCC005);
if (SH_SCC005 = .) and (SCCMISS <= 2) then SH_SCC005 = mean(of SH_SCC001-SH_SCC005);

/*score total*/
SH_SCCTP = SH_SCC001 + SH_SCC002 + SH_SCC003 + SH_SCC004 + SH_SCC005;

/*creation de lindicateur*/
SH_SCCTS_1 = 0;
if SH_SCCTP = . then SH_SCCTS_1 = .;
else if SH_SCCTP > 10 then SH_SCCTS_1 = 1;
label SH_SCCTS_1 = "&students6 have a high level of school connectedness";

/*indicateur Q23 - SH_PRO01_1 SH_PRO02_1 SH_PRO03_1 SH_PRO04_1 SH_PRO05_1*/
if SH_PRO01 = 1 then SH_PRO01_1 = 0;
if SH_PRO01 = 2 then SH_PRO01_1 = 0;
if SH_PRO01 = 3 then SH_PRO01_1 = 0;
if SH_PRO01 = 4 then SH_PRO01_1 = 1;
if SH_PRO01 = 5 then SH_PRO01_1 = 1;
if SH_PRO01 = 6 then SH_PRO01_1 = 1;
label SH_PRO01_1 = "&students6 often do favours for people without being asked";

if SH_PRO02 = 1 then SH_PRO02_1 = 0;
if SH_PRO02 = 2 then SH_PRO02_1 = 0;
if SH_PRO02 = 3 then SH_PRO02_1 = 0;
if SH_PRO02 = 4 then SH_PRO02_1 = 1;
if SH_PRO02 = 5 then SH_PRO02_1 = 1;
if SH_PRO02 = 6 then SH_PRO02_1 = 1;
label SH_PRO02_1 = "&students6 often lend things to people without being asked";

if SH_PRO03 = 1 then SH_PRO03_1 = 0;
if SH_PRO03 = 2 then SH_PRO03_1 = 0;
if SH_PRO03 = 3 then SH_PRO03_1 = 0;
if SH_PRO03 = 4 then SH_PRO03_1 = 1;
if SH_PRO03 = 5 then SH_PRO03_1 = 1;
if SH_PRO03 = 6 then SH_PRO03_1 = 1;
label SH_PRO03_1 = "&students6 often help people without being asked";

if SH_PRO04 = 1 then SH_PRO04_1 = 0;
if SH_PRO04 = 2 then SH_PRO04_1 = 0;
if SH_PRO04 = 3 then SH_PRO04_1 = 0;
if SH_PRO04 = 4 then SH_PRO04_1 = 1;
if SH_PRO04 = 5 then SH_PRO04_1 = 1;
if SH_PRO04 = 6 then SH_PRO04_1 = 1;
label SH_PRO04_1 = "&students6 often compliment people without being asked";

if SH_PRO05 = 1 then SH_PRO05_1 = 0;
if SH_PRO05 = 2 then SH_PRO05_1 = 0;
if SH_PRO05 = 3 then SH_PRO05_1 = 0;
if SH_PRO05 = 4 then SH_PRO05_1 = 1;
if SH_PRO05 = 5 then SH_PRO05_1 = 1;
if SH_PRO05 = 6 then SH_PRO05_1 = 1;
label SH_PRO05_1 = "&students6 often share things with people without being asked";

/*compte le nombre de missing pour les variables SH_PRO01-SH_PRO05 et creation dune nouvelle variable avec le nombre de miss (PROMISS)*/
array PRO(5) SH_PRO01-SH_PRO05;
PROMISS = cmiss(of PRO [*]);

/*creation d'une variable temporaire*/
SH_PRO001 = SH_PRO01;
SH_PRO002 = SH_PRO02;
SH_PRO003 = SH_PRO03;
SH_PRO004 = SH_PRO04;
SH_PRO005 = SH_PRO05;

/*remplacement des donnees manquantes (si moins que 6 manquantes) par la moyenne du sujet au score total*/
if (SH_PRO001 = .) and (PROMISS <= 2) then SH_PRO001 = mean(of SH_PRO001-SH_PRO005);
if (SH_PRO002 = .) and (PROMISS <= 2) then SH_PRO002 = mean(of SH_PRO001-SH_PRO005);
if (SH_PRO003 = .) and (PROMISS <= 2) then SH_PRO003 = mean(of SH_PRO001-SH_PRO005);
if (SH_PRO004 = .) and (PROMISS <= 2) then SH_PRO004 = mean(of SH_PRO001-SH_PRO005);
if (SH_PRO005 = .) and (PROMISS <= 2) then SH_PRO005 = mean(of SH_PRO001-SH_PRO005);

/*score total*/
SH_PROTP = SH_PRO001 + SH_PRO002 + SH_PRO003 + SH_PRO004 + SH_PRO005;

/*creation de lindicateur*/
SH_PROTS_1 = 0;
if SH_PROTP = . then SH_PROTS_1 = .;
else if SH_PROTP > 14 then SH_PROTS_1 = 1;
label SH_PROTS_1 = "&students6 have a high level of pro-social behaviours";

/*indicateur Q24 - SH_EATFV_1*/
if  (SH_EAT02 = .) and
(SH_EAT03 = .) and
(SH_EAT04 = .) and
(SH_EAT06 = .) then SH_EATFV = .;
else do;
SH_EAT02a = SH_EAT02;
SH_EAT03a = SH_EAT03;
SH_EAT04a = SH_EAT04;
SH_EAT06a = SH_EAT06;
if SH_EAT02a = . then SH_EAT02a = 0;
if SH_EAT03a = . then SH_EAT03a = 0;
if SH_EAT04a = . then SH_EAT04a = 0;
if SH_EAT06a = . then SH_EAT06a = 0;
SH_EATFV = SH_EAT02a + SH_EAT03a + SH_EAT04a + SH_EAT06a;
end;
if SH_EATFV >= 5 then SH_EATFV_1 = 1;
if SH_EATFV <  5 then SH_EATFV_1 = 0;
if SH_EATFV =  . then SH_EATFV_1 = .;
label SH_EATFV_1 = "&students6 report eating five or more servings of vegetables and fruit the day before the survey";

/*indicateur Q24 - SH_EATNN_1*/
if (SH_EAT01 = .) and (SH_EAT07 = .) and (SH_EAT08 = .) and (SH_EAT09 = .) then SH_EATNN_1 = .;
else if SH_EAT01 in (1,2,3,4,5,6) or
SH_EAT07 in (1,2,3,4,5,6) or
SH_EAT08 in (1,2,3,4,5,6) or
SH_EAT09 in (1,2,3,4,5,6) then SH_EATNN_1 = 1;
else SH_EATNN_1 = 0;
label SH_EATNN_1 = "&students6 report eating one or more serving of non-nutritious foods the day before the survey";

/*indicateur Q25 - SH_DRI01_1*/
if SH_DRI01 >= 2 then SH_DRI01_1 = 1;
if SH_DRI01 <  2 then SH_DRI01_1 = 0;
if SH_DRI01 =  . then SH_DRI01_1 = .;
label SH_DRI01_1 = "&students6 report drinking two or more servings of milk or soy beverage the day before the survey";

/*indicateur Q25 - SH_DRI07_1*/
if SH_DRI07 in (1,2,3,4,5,6) then SH_DRI07_1 = 1;
if SH_DRI07 = 0 then SH_DRI07_1 = 0;
if SH_DRI07 = . then SH_DRI07_1 = .;
label SH_DRI07_1 = "&students6 report drinking one or more serving of a high energy drink the day before the survey";

/*indicateur Q25 - SH_DRINN_1*/
if (SH_DRI03 = .) and (SH_DRI04 = .) and (SH_DRI05 = .) and (SH_DRI06 = .) and (SH_DRI07 = .) then SH_DRINN_1 = .;
else if SH_DRI03 in (1,2,3,4,5,6) or
SH_DRI04 in (1,2,3,4,5,6) or
SH_DRI05 in (1,2,3,4,5,6) or
SH_DRI06 in (1,2,3,4,5,6) or
SH_DRI07 in (1,2,3,4,5,6) then SH_DRINN_1= 1;
else SH_DRINN_1 = 0;
label SH_DRINN_1 = "&students6 report drinking one or more serving of a non-nutritious beverage the day before the survey";

/*indicateur Q26 - SH_EAT10_1 SH_EAT11_1*/
if SH_EAT10 = 0 then SH_EAT10_1 = 0;
if SH_EAT10 = 1 then SH_EAT10_1 = 0;
if SH_EAT10 = 2 then SH_EAT10_1 = 0;
if SH_EAT10 = 3 then SH_EAT10_1 = 0;
if SH_EAT10 = 4 then SH_EAT10_1 = 0;
if SH_EAT10 = 5 then SH_EAT10_1 = 0;
if SH_EAT10 = 6 then SH_EAT10_1 = 0;
if SH_EAT10 = 7 then SH_EAT10_1 = 1;
label SH_EAT10_1 = "&students6 report having an evening meal together with family, friend(s) or guardian(s) every day";

if SH_EAT11 = 0 then SH_EAT11_1 = 0;
if SH_EAT11 = 1 then SH_EAT11_1 = 0;
if SH_EAT11 = 2 then SH_EAT11_1 = 0;
if SH_EAT11 = 3 then SH_EAT11_1 = 0;
if SH_EAT11 = 4 then SH_EAT11_1 = 0;
if SH_EAT11 = 5 then SH_EAT11_1 = 0;
if SH_EAT11 = 6 then SH_EAT11_1 = 0;
if SH_EAT11 = 7 then SH_EAT11_1 = 1;
label SH_EAT11_1 = "&students6 report having a breakfast together with family, friend(s) or guardian(s) every day";

/*indicateur Q27 - SH_EAT12_1 SH_EAT13_1 SH_EAT13_2*/
if SH_EAT12 = 0 then SH_EAT12_1 = 0;
if SH_EAT12 = 1 then SH_EAT12_1 = 0;
if SH_EAT12 = 2 then SH_EAT12_1 = 0;
if SH_EAT12 = 3 then SH_EAT12_1 = 0;
if SH_EAT12 = 4 then SH_EAT12_1 = 1;
label SH_EAT12_1 = "&students6 report eating breakfast daily";

if SH_EAT13 = 0 then SH_EAT13_1 = 0;
if SH_EAT13 = 1 then SH_EAT13_1 = 1;
if SH_EAT13 = 2 then SH_EAT13_1 = 1;
if SH_EAT13 = 3 then SH_EAT13_1 = 1;
if SH_EAT13 = 4 then SH_EAT13_1 = 1;
label SH_EAT13_1 = "&students6 report eating at a fast food place or restaurant at least once in the last seven days";

if SH_EAT13 = 0 then SH_EAT13_2 = 0;
if SH_EAT13 = 1 then SH_EAT13_2 = 0;
if SH_EAT13 = 2 then SH_EAT13_2 = 1;
if SH_EAT13 = 3 then SH_EAT13_2 = 1;
if SH_EAT13 = 4 then SH_EAT13_2 = 1;
label SH_EAT13_2 = "&students6 report eating at a fast food place or restaurant three times or more in the last seven days";

/*indicateur Q27c - SH_EAT14_1*/
if SH_EAT14 = 0 then SH_EAT14_1 = 0;
if SH_EAT14 = 1 then SH_EAT14_1 = 1;
if SH_EAT14 = 2 then SH_EAT14_1 = 1;
if SH_EAT14 = 3 then SH_EAT14_1 = 1;
if SH_EAT14 = 4 then SH_EAT14_1 = 1;
label SH_EAT14_1 = "&students6 report eating at a fast food place or restaurant at least once in the last seven days";

if SH_EAT14 = 0 then SH_EAT14_2 = 0;
if SH_EAT14 = 1 then SH_EAT14_2 = 0;
if SH_EAT14 = 2 then SH_EAT14_2 = 1;
if SH_EAT14 = 3 then SH_EAT14_2 = 1;
if SH_EAT14 = 4 then SH_EAT14_2 = 1;
label SH_EAT14_2 = "&students6 report eating a meal while watching television, three times or more in the last seven days";

/*indicateur Q28 - all that applay*/
if SH_SKBEA = 1 then SH_SKBEA_1 = 1;
if SH_SKBEA = 0 then SH_SKBEA_1 = 0;
label SH_SKBEA_1 = "&students6 report eating breakfast every day";

if SH_SKBDT = 1 then SH_SKBDT_1 = 1;
if SH_SKBDT = 0 then SH_SKBDT_1 = 0;
label SH_SKBDT_1 = "&students6 report skipping breakfast because they do not have time for it";

if SH_SKBBE = 1 then SH_SKBBE_1 = 1;
if SH_SKBBE = 0 then SH_SKBBE_1 = 0;
label SH_SKBBE_1 = "&students6 report skipping breakfast because the bus comes too early";

if SH_SKBSI = 1 then SH_SKBSI_1 = 1;
if SH_SKBSI = 0 then SH_SKBSI_1 = 0;
label SH_SKBSI_1 = "&students6 report skipping breakfast because they sleep in";

if SH_SKBHM = 1 then SH_SKBHM_1 = 1;
if SH_SKBHM = 0 then SH_SKBHM_1 = 0;
label SH_SKBHM_1 = "&students6 report skipping breakfast because they are not hungry in the morning";

if SH_SKBFS = 1 then SH_SKBFS_1 = 1;
if SH_SKBFS = 0 then SH_SKBFS_1 = 0;
label SH_SKBFS_1 = "&students6 report skipping breakfast because they feel sick when they eat it";

if SH_SKBLW = 1 then SH_SKBLW_1 = 1;
if SH_SKBLW = 0 then SH_SKBLW_1 = 0;
label SH_SKBLW_1 = "&students6 report skipping breakfast because they are trying to lose weight";

if SH_SKBNE = 1 then SH_SKBNE_1 = 1;
if SH_SKBNE = 0 then SH_SKBNE_1 = 0;
label SH_SKBNE_1 = "&students6 report skipping breakfast because there is nothing to eat at home";

if SH_SKBOT = 1 then SH_SKBOT_1 = 1;
if SH_SKBOT = 0 then SH_SKBOT_1 = 0;
label SH_SKBOT_1 = "&students6 report skipping breakfast for another reason";

/*indicateur Q29 - SH_SCF01_1*/
if SH_SCF01 = 1 then SH_SCF01_1 = 1;
if SH_SCF01 = 2 then SH_SCF01_1 = 0;
if SH_SCF01 = 3 then SH_SCF01_1 = 0;
if SH_SCF01 = 4 then SH_SCF01_1 = 0;
if SH_SCF01 = 5 then SH_SCF01_1 = 0;
label SH_SCF01_1 = "&students6 think that there is not enough variety of foods offered at their school (cafeteria, hot lunch, vending machines, and canteen)";

/*indicateur Q30 - All that apply*/
if SH_SCFBP = 1 then SH_SCFBP_1 = 1;
if SH_SCFBP = 0 then SH_SCFBP_1 = 0;
label SH_SCFBP_1 = "&students6 report having noticed a breakfast program at their school in the last 12 months";

if SH_SCFFV = 1 then SH_SCFFV_1 = 1;
if SH_SCFFV = 0 then SH_SCFFV_1 = 0;
label SH_SCFFV_1 = "&students6 report having noticed a fruit and vegetable snack program at their school in the last 12 months";

if SH_SCFHE = 1 then SH_SCFHE_1 = 1;
if SH_SCFHE = 0 then SH_SCFHE_1 = 0;
label SH_SCFHE_1 = "&students6 report having noticed healthy foods sold at sporting events or special food events (e.g., dances and movie nights) at their school in the last 12 months";

if SH_SCFHF = 1 then SH_SCFHF_1 = 1;
if SH_SCFHF = 0 then SH_SCFHF_1 = 0;
label SH_SCFHF_1 = "&students6 report having noticed healthy foods or non-food items sold for fundraising at their school in the last 12 months";

if SH_SCFHV = 1 then SH_SCFHV_1 = 1;
if SH_SCFHV = 0 then SH_SCFHV_1 = 0;
label SH_SCFHV_1 = "&students6 report having noticed healthy foods offered in vending machines and at canteens at their school in the last 12 months";

if SH_SCFHC = 1 then SH_SCFHC_1 = 1;
if SH_SCFHC = 0 then SH_SCFHC_1 = 0;
label SH_SCFHC_1 = "&students6 report having noticed healthy foods offered at cafeteria or in hot lunch program in the last 12 months";

if SH_SCFIC = 1 then SH_SCFIC_1 = 1;
if SH_SCFIC = 0 then SH_SCFIC_1 = 0;
label SH_SCFIC_1 = "&students6 report having noticed information in the school cafeteria about how to make healthier food choices in the last 12 months";

if SH_SCFLP = 1 then SH_SCFLP_1 = 1;
if SH_SCFLP = 0 then SH_SCFLP_1 = 0;
label SH_SCFLP_1 = "&students6 report having noticed lower prices for healthier foods at their school in the last 12 months";

if SH_SCFSS = 1 then SH_SCFSS_1 = 1;
if SH_SCFSS = 0 then SH_SCFSS_1 = 0;
label SH_SCFSS_1 = "&students6 report having noticed school staff (teachers, custodians) show a positive attitude towards healthy living and health related issues at their school in the last 12 months";

/*indicateur Q31 - SH_FIN01_1*/
if SH_FIN01 = 1 then SH_FIN01_1 = 0;
if SH_FIN01 = 2 then SH_FIN01_1 = 0;
if SH_FIN01 = 3 then SH_FIN01_1 = 1;
if SH_FIN01 = 4 then SH_FIN01_1 = 1;
label SH_FIN01_1 = "&students6 often or always go to school or to bed hungry because there is not enough food at home";

/*MENTAL FITNESS*/
/*indicateur Q32 - SH_MEFLO_1 SH_MEFMO_1 SH_MEFHI_1  SH_MEFAU_1 SH_MEFCO_1 SH_MEFRE_1 SH_MEFFA_1 SH_MEFFR_1 SH_MEFSC_1*/
/*compte le nombre de missing pour les variables SH_MEF01-SH_MEF18 et creation dune nouvelle variable avec le nombre de miss (MEFMISS)*/

/*total*/
array MEFT(18) SH_MEF01-SH_MEF18;
MEFTMISS = cmiss(of MEFT [*]);

/*autonomy*/
array MEFA(6) SH_MEF03 SH_MEF06 SH_MEF09 SH_MEF12 SH_MEF15 SH_MEF18;
MEFAMISS = cmiss(of MEFA [*]);

/*competence*/
array MEFC(6) SH_MEF01 SH_MEF04 SH_MEF07 SH_MEF10 SH_MEF13 SH_MEF16;
MEFCMISS = cmiss(of MEFC [*]);

/*relatedness*/
array MEFR(6) SH_MEF02 SH_MEF05 SH_MEF08 SH_MEF11 SH_MEF14 SH_MEF17;
MEFRMISS = cmiss(of MEFR [*]);

/*family-related*/
array MEFF(6) SH_MEF03 SH_MEF05 SH_MEF07 SH_MEF08 SH_MEF10 SH_MEF18;
MEFFMISS = cmiss(of MEFF [*]);

/*friends-related*/
array MEFI(6) SH_MEF06 SH_MEF12 SH_MEF13 SH_MEF14 SH_MEF16 SH_MEF17;
MEFIMISS = cmiss(of MEFI [*]);

/*school-related*/
array MEFS(6) SH_MEF01 SH_MEF02 SH_MEF04 SH_MEF09 SH_MEF11 SH_MEF15;
MEFSMISS = cmiss(of MEFS [*]);

/*creation des variables temporaires - total*/
SH_MEF001 = SH_MEF01;
SH_MEF002 = SH_MEF02;
SH_MEF003 = SH_MEF03;
SH_MEF004 = SH_MEF04;
SH_MEF005 = SH_MEF05;
SH_MEF006 = SH_MEF06;
SH_MEF007 = SH_MEF07;
SH_MEF008 = SH_MEF08;
SH_MEF009 = SH_MEF09;
SH_MEF010 = SH_MEF10;
SH_MEF011 = SH_MEF11;
SH_MEF012 = SH_MEF12;
SH_MEF013 = SH_MEF13;
SH_MEF014 = SH_MEF14;
SH_MEF015 = SH_MEF15;
SH_MEF016 = SH_MEF16;
SH_MEF017 = SH_MEF17;
SH_MEF018 = SH_MEF18;

/*creation des variables temporaires - autonomy*/
SH_MEF03A = SH_MEF03;
SH_MEF06A = SH_MEF06;
SH_MEF09A = SH_MEF09;
SH_MEF12A = SH_MEF12;
SH_MEF15A = SH_MEF15;
SH_MEF18A = SH_MEF18;

/*creation des variables temporaires - competence*/
SH_MEF01C = SH_MEF01;
SH_MEF04C = SH_MEF04;
SH_MEF07C = SH_MEF07;
SH_MEF10C = SH_MEF10;
SH_MEF13C = SH_MEF13;
SH_MEF16C = SH_MEF16;

/*creation des variables temporaires - relatedness*/
SH_MEF02R = SH_MEF02;
SH_MEF05R = SH_MEF05;
SH_MEF08R = SH_MEF08;
SH_MEF11R = SH_MEF11;
SH_MEF14R = SH_MEF14;
SH_MEF17R = SH_MEF17;

/*creation des variables temporaires - family-related*/
SH_MEF03F = SH_MEF03;
SH_MEF05F = SH_MEF05;
SH_MEF07F = SH_MEF07;
SH_MEF08F = SH_MEF08;
SH_MEF10F = SH_MEF10;
SH_MEF18F = SH_MEF18;

/*creation des variables temporaires - friends-related*/
SH_MEF06I = SH_MEF06;
SH_MEF12I = SH_MEF12;
SH_MEF13I = SH_MEF13;
SH_MEF14I = SH_MEF14;
SH_MEF16I = SH_MEF16;
SH_MEF17I = SH_MEF17;

/*creation des variables temporaires - school-related*/
SH_MEF01S = SH_MEF01;
SH_MEF02S = SH_MEF02;
SH_MEF04S = SH_MEF04;
SH_MEF09S = SH_MEF09;
SH_MEF11S = SH_MEF11;
SH_MEF15S = SH_MEF15;

/*remplacement des donnees manquantes par la moyenne du sujet - total*/
if (SH_MEF001 = .) and (MEFTMISS <= 8) then SH_MEF001 = mean(of SH_MEF001-SH_MEF018);
if (SH_MEF002 = .) and (MEFTMISS <= 8) then SH_MEF002 = mean(of SH_MEF001-SH_MEF018);
if (SH_MEF003 = .) and (MEFTMISS <= 8) then SH_MEF003 = mean(of SH_MEF001-SH_MEF018);
if (SH_MEF004 = .) and (MEFTMISS <= 8) then SH_MEF004 = mean(of SH_MEF001-SH_MEF018);
if (SH_MEF005 = .) and (MEFTMISS <= 8) then SH_MEF005 = mean(of SH_MEF001-SH_MEF018);
if (SH_MEF006 = .) and (MEFTMISS <= 8) then SH_MEF006 = mean(of SH_MEF001-SH_MEF018);
if (SH_MEF007 = .) and (MEFTMISS <= 8) then SH_MEF007 = mean(of SH_MEF001-SH_MEF018);
if (SH_MEF008 = .) and (MEFTMISS <= 8) then SH_MEF008 = mean(of SH_MEF001-SH_MEF018);
if (SH_MEF009 = .) and (MEFTMISS <= 8) then SH_MEF009 = mean(of SH_MEF001-SH_MEF018);
if (SH_MEF010 = .) and (MEFTMISS <= 8) then SH_MEF010 = mean(of SH_MEF001-SH_MEF018);
if (SH_MEF011 = .) and (MEFTMISS <= 8) then SH_MEF011 = mean(of SH_MEF001-SH_MEF018);
if (SH_MEF012 = .) and (MEFTMISS <= 8) then SH_MEF012 = mean(of SH_MEF001-SH_MEF018);
if (SH_MEF013 = .) and (MEFTMISS <= 8) then SH_MEF013 = mean(of SH_MEF001-SH_MEF018);
if (SH_MEF014 = .) and (MEFTMISS <= 8) then SH_MEF014 = mean(of SH_MEF001-SH_MEF018);
if (SH_MEF015 = .) and (MEFTMISS <= 8) then SH_MEF015 = mean(of SH_MEF001-SH_MEF018);
if (SH_MEF016 = .) and (MEFTMISS <= 8) then SH_MEF016 = mean(of SH_MEF001-SH_MEF018);
if (SH_MEF017 = .) and (MEFTMISS <= 8) then SH_MEF017 = mean(of SH_MEF001-SH_MEF018);
if (SH_MEF018 = .) and (MEFTMISS <= 8) then SH_MEF018 = mean(of SH_MEF001-SH_MEF018);

/*remplacement des donnees manquantes par la moyenne du sujet - autonomy*/
if (SH_MEF03A = .) and (MEFAMISS <= 2) then SH_MEF03A = mean(of SH_MEF03A SH_MEF06A SH_MEF09A SH_MEF12A SH_MEF15A SH_MEF18A);
if (SH_MEF06A = .) and (MEFAMISS <= 2) then SH_MEF06A = mean(of SH_MEF03A SH_MEF06A SH_MEF09A SH_MEF12A SH_MEF15A SH_MEF18A);
if (SH_MEF09A = .) and (MEFAMISS <= 2) then SH_MEF09A = mean(of SH_MEF03A SH_MEF06A SH_MEF09A SH_MEF12A SH_MEF15A SH_MEF18A);
if (SH_MEF12A = .) and (MEFAMISS <= 2) then SH_MEF12A = mean(of SH_MEF03A SH_MEF06A SH_MEF09A SH_MEF12A SH_MEF15A SH_MEF18A);
if (SH_MEF15A = .) and (MEFAMISS <= 2) then SH_MEF15A = mean(of SH_MEF03A SH_MEF06A SH_MEF09A SH_MEF12A SH_MEF15A SH_MEF18A);
if (SH_MEF18A = .) and (MEFAMISS <= 2) then SH_MEF18A = mean(of SH_MEF03A SH_MEF06A SH_MEF09A SH_MEF12A SH_MEF15A SH_MEF18A);

/*remplacement des donnees manquantes par la moyenne du sujet - competence*/
if (SH_MEF01C = .) and (MEFCMISS <= 2) then SH_MEF01C = mean(of SH_MEF01C SH_MEF04C SH_MEF07C SH_MEF10C SH_MEF13C SH_MEF16C);
if (SH_MEF04C = .) and (MEFCMISS <= 2) then SH_MEF04C = mean(of SH_MEF01C SH_MEF04C SH_MEF07C SH_MEF10C SH_MEF13C SH_MEF16C);
if (SH_MEF07C = .) and (MEFCMISS <= 2) then SH_MEF07C = mean(of SH_MEF01C SH_MEF04C SH_MEF07C SH_MEF10C SH_MEF13C SH_MEF16C);
if (SH_MEF10C = .) and (MEFCMISS <= 2) then SH_MEF10C = mean(of SH_MEF01C SH_MEF04C SH_MEF07C SH_MEF10C SH_MEF13C SH_MEF16C);
if (SH_MEF13C = .) and (MEFCMISS <= 2) then SH_MEF13C = mean(of SH_MEF01C SH_MEF04C SH_MEF07C SH_MEF10C SH_MEF13C SH_MEF16C);
if (SH_MEF16C = .) and (MEFCMISS <= 2) then SH_MEF16C = mean(of SH_MEF01C SH_MEF04C SH_MEF07C SH_MEF10C SH_MEF13C SH_MEF16C);

/*remplacement des donnees manquantes par la moyenne du sujet - relatedness*/
if (SH_MEF02R = .) and (MEFRMISS <= 2) then SH_MEF02R = mean(of SH_MEF02R SH_MEF05R SH_MEF08R SH_MEF11R SH_MEF14R SH_MEF17R);
if (SH_MEF05R = .) and (MEFRMISS <= 2) then SH_MEF05R = mean(of SH_MEF02R SH_MEF05R SH_MEF08R SH_MEF11R SH_MEF14R SH_MEF17R);
if (SH_MEF08R = .) and (MEFRMISS <= 2) then SH_MEF08R = mean(of SH_MEF02R SH_MEF05R SH_MEF08R SH_MEF11R SH_MEF14R SH_MEF17R);
if (SH_MEF11R = .) and (MEFRMISS <= 2) then SH_MEF11R = mean(of SH_MEF02R SH_MEF05R SH_MEF08R SH_MEF11R SH_MEF14R SH_MEF17R);
if (SH_MEF14R = .) and (MEFRMISS <= 2) then SH_MEF14R = mean(of SH_MEF02R SH_MEF05R SH_MEF08R SH_MEF11R SH_MEF14R SH_MEF17R);
if (SH_MEF17R = .) and (MEFRMISS <= 2) then SH_MEF17R = mean(of SH_MEF02R SH_MEF05R SH_MEF08R SH_MEF11R SH_MEF14R SH_MEF17R);

/*remplacement des donnees manquantes par la moyenne du sujet - family-related*/
if (SH_MEF03F = .) and (MEFFMISS <= 2) then SH_MEF03F = mean(of SH_MEF03F SH_MEF05F SH_MEF07F SH_MEF08F SH_MEF10F SH_MEF18F);
if (SH_MEF05F = .) and (MEFFMISS <= 2) then SH_MEF05F = mean(of SH_MEF03F SH_MEF05F SH_MEF07F SH_MEF08F SH_MEF10F SH_MEF18F);
if (SH_MEF07F = .) and (MEFFMISS <= 2) then SH_MEF07F = mean(of SH_MEF03F SH_MEF05F SH_MEF07F SH_MEF08F SH_MEF10F SH_MEF18F);
if (SH_MEF08F = .) and (MEFFMISS <= 2) then SH_MEF08F = mean(of SH_MEF03F SH_MEF05F SH_MEF07F SH_MEF08F SH_MEF10F SH_MEF18F);
if (SH_MEF10F = .) and (MEFFMISS <= 2) then SH_MEF10F = mean(of SH_MEF03F SH_MEF05F SH_MEF07F SH_MEF08F SH_MEF10F SH_MEF18F);
if (SH_MEF18F = .) and (MEFFMISS <= 2) then SH_MEF18F = mean(of SH_MEF03F SH_MEF05F SH_MEF07F SH_MEF08F SH_MEF10F SH_MEF18F);

/*remplacement des donnees manquantes par la moyenne du sujet - friends-related*/
if (SH_MEF06I = .) and (MEFIMISS <= 2) then SH_MEF06I = mean(of SH_MEF06I SH_MEF12I SH_MEF13I SH_MEF14I SH_MEF16I SH_MEF17I);
if (SH_MEF12I = .) and (MEFIMISS <= 2) then SH_MEF12I = mean(of SH_MEF06I SH_MEF12I SH_MEF13I SH_MEF14I SH_MEF16I SH_MEF17I);
if (SH_MEF13I = .) and (MEFIMISS <= 2) then SH_MEF13I = mean(of SH_MEF06I SH_MEF12I SH_MEF13I SH_MEF14I SH_MEF16I SH_MEF17I);
if (SH_MEF14I = .) and (MEFIMISS <= 2) then SH_MEF14I = mean(of SH_MEF06I SH_MEF12I SH_MEF13I SH_MEF14I SH_MEF16I SH_MEF17I);
if (SH_MEF16I = .) and (MEFIMISS <= 2) then SH_MEF16I = mean(of SH_MEF06I SH_MEF12I SH_MEF13I SH_MEF14I SH_MEF16I SH_MEF17I);
if (SH_MEF17I = .) and (MEFIMISS <= 2) then SH_MEF17I = mean(of SH_MEF06I SH_MEF12I SH_MEF13I SH_MEF14I SH_MEF16I SH_MEF17I);

/*remplacement des donnees manquantes par la moyenne du sujet - school-related*/
if (SH_MEF01S = .) and (MEFSMISS <= 2) then SH_MEF01S = mean(of SH_MEF01S SH_MEF02S SH_MEF04S SH_MEF09S SH_MEF11S SH_MEF15S);
if (SH_MEF02S = .) and (MEFSMISS <= 2) then SH_MEF02S = mean(of SH_MEF01S SH_MEF02S SH_MEF04S SH_MEF09S SH_MEF11S SH_MEF15S);
if (SH_MEF04S = .) and (MEFSMISS <= 2) then SH_MEF04S = mean(of SH_MEF01S SH_MEF02S SH_MEF04S SH_MEF09S SH_MEF11S SH_MEF15S);
if (SH_MEF09S = .) and (MEFSMISS <= 2) then SH_MEF09S = mean(of SH_MEF01S SH_MEF02S SH_MEF04S SH_MEF09S SH_MEF11S SH_MEF15S);
if (SH_MEF11S = .) and (MEFSMISS <= 2) then SH_MEF11S = mean(of SH_MEF01S SH_MEF02S SH_MEF04S SH_MEF09S SH_MEF11S SH_MEF15S);
if (SH_MEF15S = .) and (MEFSMISS <= 2) then SH_MEF15S = mean(of SH_MEF01S SH_MEF02S SH_MEF04S SH_MEF09S SH_MEF11S SH_MEF15S);

/*score total*/
SH_MEFTO = SH_MEF001 + SH_MEF002 + SH_MEF003 + SH_MEF004 + SH_MEF005 + SH_MEF006 + SH_MEF007 + SH_MEF008 + SH_MEF009 +
SH_MEF010 + SH_MEF011 + SH_MEF012 + SH_MEF013 + SH_MEF014 + SH_MEF015 + SH_MEF016 + SH_MEF017 + SH_MEF018;

/*autonomy*/
SH_MEFAU = SH_MEF03A + SH_MEF06A + SH_MEF09A + SH_MEF12A + SH_MEF15A + SH_MEF18A;

/*competence*/
SH_MEFCO = SH_MEF01C + SH_MEF04C + SH_MEF07C + SH_MEF10C + SH_MEF13C + SH_MEF16C;

/*relatedness*/
SH_MEFRE = SH_MEF02R + SH_MEF05R + SH_MEF08R + SH_MEF11R + SH_MEF14R + SH_MEF17R;

/*family-related*/
SH_MEFFA = SH_MEF03F + SH_MEF05F + SH_MEF07F + SH_MEF08F + SH_MEF10F + SH_MEF18F;

/*friends-related*/
SH_MEFFR = SH_MEF06I + SH_MEF12I + SH_MEF13I + SH_MEF14I + SH_MEF16I + SH_MEF17I;

/*school-related*/
SH_MEFSC = SH_MEF01S + SH_MEF02S + SH_MEF04S + SH_MEF09S + SH_MEF11S + SH_MEF15S;

/*creation des indicateurs*/
SH_MEFLO_1 = 0;
if SH_MEFTO = . then SH_MEFLO_1 = .;
else if SH_MEFTO <= 51 then SH_MEFLO_1 = 1;
label SH_MEFLO_1  = "&students6 have a low level of mental fitness";

SH_MEFMO_1 = 0;
if SH_MEFTO = . then SH_MEFMO_1 = .;
else if (SH_MEFTO > 51) and (SH_MEFTO <= 65) then SH_MEFMO_1 = 1;
label SH_MEFMO_1 = "&students6 have a moderate level of mental fitness";

SH_MEFHI_1 = 0;
if SH_MEFTO = . then SH_MEFHI_1 = .;
else if SH_MEFTO > 65 then SH_MEFHI_1 = 1;
label SH_MEFHI_1 = "&students6 have a high level of mental fitness";

SH_MEFHM_1 = 0;
if (SH_MEFMO_1 = .) or (SH_MEFHI_1 = .) then SH_MEFHM_1 = .;
else if (SH_MEFMO_1 = 1) or (SH_MEFHI_1 = 1) then SH_MEFHM_1 = 1;
label SH_MEFHM_1 = "&students6 have a high level or moderate level of mental fitness";

SH_MEFAU_1 = 0;
if SH_MEFAU = . then SH_MEFAU_1 = .;
else if SH_MEFAU >= 18 then SH_MEFAU_1 = 1;
label SH_MEFAU_1  = "&students6 have their need for autonomy highly satisfied";

SH_MEFCO_1 = 0;
if SH_MEFCO = . then SH_MEFCO_1 = .;
else if SH_MEFCO >= 18 then SH_MEFCO_1 = 1;
label SH_MEFCO_1  = "&students6 have their need for competence highly satisfied";

SH_MEFRE_1 = 0;
if SH_MEFRE = . then SH_MEFRE_1 = .;
else if SH_MEFRE >= 18 then SH_MEFRE_1 = 1;
label SH_MEFRE_1  = "&students6 have their need for relatedness highly satisfied";

SH_MEFFA_1 = 0;
if SH_MEFFA = . then SH_MEFFA_1 = .;
else if SH_MEFFA >= 18 then SH_MEFFA_1 = 1;
label SH_MEFFA_1  = "&students6 have their basic psychological needs highly met by their family";

SH_MEFFR_1 = 0;
if SH_MEFFR = . then SH_MEFFR_1 = .;
else if SH_MEFFR >= 18 then SH_MEFFR_1 = 1;
label SH_MEFFR_1  = "&students6 have their basic psychological needs highly met by their friends";

SH_MEFSC_1 = 0;
if SH_MEFSC = . then SH_MEFSC_1 = .;
else if SH_MEFSC >= 18 then SH_MEFSC_1 = 1;
label SH_MEFSC_1  = "&students6 have their basic psychological needs highly met by their school";

/*indicateur Q32 - SH_MEF01_1 SH_MEF02_1 SH_MEF03_1 SH_MEF04_1 SH_MEF05_1 SH_MEF06_1 SH_MEF07_1 SH_MEF08_1 SH_MEF09_1
SH_MEF10_1 SH_MEF11_1 SH_MEF12_1 SH_MEF13_1 SH_MEF14_1 SH_MEF15_1 SH_MEF16_1 SH_MEF17_1 SH_MEF18_1*/
if SH_MEF01 = 1 then SH_MEF01_1 = 0;
if SH_MEF01 = 2 then SH_MEF01_1 = 0;
if SH_MEF01 = 3 then SH_MEF01_1 = 0;
if SH_MEF01 = 4 then SH_MEF01_1 = 1;
label SH_MEF01_1  = "&students6 report feeling they do things well at school";

if SH_MEF02 = 1 then SH_MEF02_1 = 0;
if SH_MEF02 = 2 then SH_MEF02_1 = 0;
if SH_MEF02 = 3 then SH_MEF02_1 = 0;
if SH_MEF02 = 4 then SH_MEF02_1 = 1;
label SH_MEF02_1  = "&students6 report feeling their teachers like them and care about them";

if SH_MEF03 = 1 then SH_MEF03_1 = 0;
if SH_MEF03 = 2 then SH_MEF03_1 = 0;
if SH_MEF03 = 3 then SH_MEF03_1 = 0;
if SH_MEF03 = 4 then SH_MEF03_1 = 1;
label SH_MEF03_1  = "&students6 report feeling free to express themselves at home";

if SH_MEF04 = 1 then SH_MEF04_1 = 0;
if SH_MEF04 = 2 then SH_MEF04_1 = 0;
if SH_MEF04 = 3 then SH_MEF04_1 = 0;
if SH_MEF04 = 4 then SH_MEF04_1 = 1;
label SH_MEF04_1  = "&students6 report feeling their teachers think they are good at things";

if SH_MEF05 = 1 then SH_MEF05_1 = 0;
if SH_MEF05 = 2 then SH_MEF05_1 = 0;
if SH_MEF05 = 3 then SH_MEF05_1 = 0;
if SH_MEF05 = 4 then SH_MEF05_1 = 1;
label SH_MEF05_1  = "&students6 report feeling they like to spend time with their parents";

if SH_MEF06 = 1 then SH_MEF06_1 = 0;
if SH_MEF06 = 2 then SH_MEF06_1 = 0;
if SH_MEF06 = 3 then SH_MEF06_1 = 0;
if SH_MEF06 = 4 then SH_MEF06_1 = 1;
label SH_MEF06_1  = "&students6 report feeling free to express themselves with their friends";

if SH_MEF07 = 1 then SH_MEF07_1 = 0;
if SH_MEF07 = 2 then SH_MEF07_1 = 0;
if SH_MEF07 = 3 then SH_MEF07_1 = 0;
if SH_MEF07 = 4 then SH_MEF07_1 = 1;
label SH_MEF07_1  = "&students6 report feeling they do things well at home";

if SH_MEF08 = 1 then SH_MEF08_1 = 0;
if SH_MEF08 = 2 then SH_MEF08_1 = 0;
if SH_MEF08 = 3 then SH_MEF08_1 = 0;
if SH_MEF08 = 4 then SH_MEF08_1 = 1;
label SH_MEF08_1  = "&students6 report feeling their parents like them and care about them";

if SH_MEF09 = 1 then SH_MEF09_1 = 0;
if SH_MEF09 = 2 then SH_MEF09_1 = 0;
if SH_MEF09 = 3 then SH_MEF09_1 = 0;
if SH_MEF09 = 4 then SH_MEF09_1 = 1;
label SH_MEF09_1  = "&students6 report feeling they have a choice about when and how to do their schoolwork";

if SH_MEF10 = 1 then SH_MEF10_1 = 0;
if SH_MEF10 = 2 then SH_MEF10_1 = 0;
if SH_MEF10 = 3 then SH_MEF10_1 = 0;
if SH_MEF10 = 4 then SH_MEF10_1 = 1;
label SH_MEF10_1  = "&students6 report feeling their parents think that they are good at things";

if SH_MEF11 = 1 then SH_MEF11_1 = 0;
if SH_MEF11 = 2 then SH_MEF11_1 = 0;
if SH_MEF11 = 3 then SH_MEF11_1 = 0;
if SH_MEF11 = 4 then SH_MEF11_1 = 1;
label SH_MEF11_1  = "&students6 report feeling they like to be with their teachers";

if SH_MEF12 = 1 then SH_MEF12_1 = 0;
if SH_MEF12 = 2 then SH_MEF12_1 = 0;
if SH_MEF12 = 3 then SH_MEF12_1 = 0;
if SH_MEF12 = 4 then SH_MEF12_1 = 1;
label SH_MEF12_1  = "&students6 report feeling they have a choice about which activities to do with their friends";

if SH_MEF13 = 1 then SH_MEF13_1 = 0;
if SH_MEF13 = 2 then SH_MEF13_1 = 0;
if SH_MEF13 = 3 then SH_MEF13_1 = 0;
if SH_MEF13 = 4 then SH_MEF13_1 = 1;
label SH_MEF13_1  = "&students6 report feeling they do things well when they are with their friends";

if SH_MEF14 = 1 then SH_MEF14_1 = 0;
if SH_MEF14 = 2 then SH_MEF14_1 = 0;
if SH_MEF14 = 3 then SH_MEF14_1 = 0;
if SH_MEF14 = 4 then SH_MEF14_1 = 1;
label SH_MEF14_1  = "&students6 report feeling their friends like them and care about them";

if SH_MEF15 = 1 then SH_MEF15_1 = 0;
if SH_MEF15 = 2 then SH_MEF15_1 = 0;
if SH_MEF15 = 3 then SH_MEF15_1 = 0;
if SH_MEF15 = 4 then SH_MEF15_1 = 1;
label SH_MEF15_1  = "&students6 report feeling free to express themselves at school";

if SH_MEF16 = 1 then SH_MEF16_1 = 0;
if SH_MEF16 = 2 then SH_MEF16_1 = 0;
if SH_MEF16 = 3 then SH_MEF16_1 = 0;
if SH_MEF16 = 4 then SH_MEF16_1 = 1;
label SH_MEF16_1  = "&students6 report feeling their friends think they are good at things";

if SH_MEF17 = 1 then SH_MEF17_1 = 0;
if SH_MEF17 = 2 then SH_MEF17_1 = 0;
if SH_MEF17 = 3 then SH_MEF17_1 = 0;
if SH_MEF17 = 4 then SH_MEF17_1 = 1;
label SH_MEF17_1  = "&students6 report feeling they like to spend time with their friends";

if SH_MEF18 = 1 then SH_MEF18_1 = 0;
if SH_MEF18 = 2 then SH_MEF18_1 = 0;
if SH_MEF18 = 3 then SH_MEF18_1 = 0;
if SH_MEF18 = 4 then SH_MEF18_1 = 1;
label SH_MEF18_1  = "&students6 report feeling they have a choice about when and how to do their household chores";

/*RESILIENCE*/
/*indicateur Q33 - SH_RES01_1 SH_RES02_1 SH_RES03_1 SH_RES04_1 SH_RES05_1 SH_RES06_1 SH_RES07_1 SH_RES08_1 SH_RES09_1 SH_RES10_1 SH_RES11_1 SH_RES12_1 SH_RESTS_1 SH_RESTS_2*/
if SH_RES01 = 1 then SH_RES01_1 = 0;
if SH_RES01 = 2 then SH_RES01_1 = 0;
if SH_RES01 = 3 then SH_RES01_1 = 0;
if SH_RES01 = 4 then SH_RES01_1 = 0;
if SH_RES01 = 5 then SH_RES01_1 = 1;
label SH_RES01_1 = "&students6 report they are able to solve problems without harming themselves or others";

if SH_RES02 = 1 then SH_RES02_1 = 0;
if SH_RES02 = 2 then SH_RES02_1 = 0;
if SH_RES02 = 3 then SH_RES02_1 = 0;
if SH_RES02 = 4 then SH_RES02_1 = 0;
if SH_RES02 = 5 then SH_RES02_1 = 1;
label SH_RES02_1 = "&students6 report they know where to go in their community to get help";

if SH_RES03 = 1 then SH_RES03_1 = 0;
if SH_RES03 = 2 then SH_RES03_1 = 0;
if SH_RES03 = 3 then SH_RES03_1 = 0;
if SH_RES03 = 4 then SH_RES03_1 = 0;
if SH_RES03 = 5 then SH_RES03_1 = 1;
label SH_RES03_1 = "&students6 report that getting an education is important to them";

if SH_RES04 = 1 then SH_RES04_1 = 0;
if SH_RES04 = 2 then SH_RES04_1 = 0;
if SH_RES04 = 3 then SH_RES04_1 = 0;
if SH_RES04 = 4 then SH_RES04_1 = 0;
if SH_RES04 = 5 then SH_RES04_1 = 1;
label SH_RES04_1 = "&students6 report they try to finish what they start";

if SH_RES05 = 1 then SH_RES05_1 = 0;
if SH_RES05 = 2 then SH_RES05_1 = 0;
if SH_RES05 = 3 then SH_RES05_1 = 0;
if SH_RES05 = 4 then SH_RES05_1 = 0;
if SH_RES05 = 5 then SH_RES05_1 = 1;
label SH_RES05_1 = "&students6 report they have people they look up to";

if SH_RES06 = 1 then SH_RES06_1 = 0;
if SH_RES06 = 2 then SH_RES06_1 = 0;
if SH_RES06 = 3 then SH_RES06_1 = 0;
if SH_RES06 = 4 then SH_RES06_1 = 0;
if SH_RES06 = 5 then SH_RES06_1 = 1;
label SH_RES06_1 = "&students6 report their parent(s)/caregiver(s) know a lot about them";

if SH_RES07 = 1 then SH_RES07_1 = 0;
if SH_RES07 = 2 then SH_RES07_1 = 0;
if SH_RES07 = 3 then SH_RES07_1 = 0;
if SH_RES07 = 4 then SH_RES07_1 = 0;
if SH_RES07 = 5 then SH_RES07_1 = 1;
label SH_RES07_1 = "&students6 report their family stands by them during difficult times";

if SH_RES08 = 1 then SH_RES08_1 = 0;
if SH_RES08 = 2 then SH_RES08_1 = 0;
if SH_RES08 = 3 then SH_RES08_1 = 0;
if SH_RES08 = 4 then SH_RES08_1 = 0;
if SH_RES08 = 5 then SH_RES08_1 = 1;
label SH_RES08_1 = "&students6 report their friends stand by them during difficult times";

if SH_RES09 = 1 then SH_RES09_1 = 0;
if SH_RES09 = 2 then SH_RES09_1 = 0;
if SH_RES09 = 3 then SH_RES09_1 = 0;
if SH_RES09 = 4 then SH_RES09_1 = 0;
if SH_RES09 = 5 then SH_RES09_1 = 1;
label SH_RES09_1 = "&students6 report they have opportunities to develop skills that will be useful later in life";

if SH_RES10 = 1 then SH_RES10_1 = 0;
if SH_RES10 = 2 then SH_RES10_1 = 0;
if SH_RES10 = 3 then SH_RES10_1 = 0;
if SH_RES10 = 4 then SH_RES10_1 = 0;
if SH_RES10 = 5 then SH_RES10_1 = 1;
label SH_RES10_1 = "&students6 report they are treated fairly in their community";

if SH_RES11 = 1 then SH_RES11_1 = 0;
if SH_RES11 = 2 then SH_RES11_1 = 0;
if SH_RES11 = 3 then SH_RES11_1 = 0;
if SH_RES11 = 4 then SH_RES11_1 = 0;
if SH_RES11 = 5 then SH_RES11_1 = 1;
label SH_RES11_1 = "&students6 report they feel they belong at their school";

if SH_RES12 = 1 then SH_RES12_1 = 0;
if SH_RES12 = 2 then SH_RES12_1 = 0;
if SH_RES12 = 3 then SH_RES12_1 = 0;
if SH_RES12 = 4 then SH_RES12_1 = 0;
if SH_RES12 = 5 then SH_RES12_1 = 1;
label SH_RES12_1 = "&students6 report they enjoy their cultural and family traditions";

/*compte le nombre de missing pour les variables SH_MEF01-SH_MEF18 et creation dune nouvelle variable avec le nombre de miss (RESMISS)*/
array RES(12) SH_RES01-SH_RES12;
RESMISS = cmiss(of RES [*]);

/*creation d'une variable temporaire*/
SH_RES001 = SH_RES01;
SH_RES002 = SH_RES02;
SH_RES003 = SH_RES03;
SH_RES004 = SH_RES04;
SH_RES005 = SH_RES05;
SH_RES006 = SH_RES06;
SH_RES007 = SH_RES07;
SH_RES008 = SH_RES08;
SH_RES009 = SH_RES09;
SH_RES010 = SH_RES10;
SH_RES011 = SH_RES11;
SH_RES012 = SH_RES12;

/*remplacement des donnees manquantes (si moins que 6 manquantes) par la moyenne du sujet au score total*/
if (SH_RES001 = .) and (RESMISS <= 5) then SH_RES001 = mean(of SH_RES001-SH_RES012);
if (SH_RES002 = .) and (RESMISS <= 5) then SH_RES002 = mean(of SH_RES001-SH_RES012);
if (SH_RES003 = .) and (RESMISS <= 5) then SH_RES003 = mean(of SH_RES001-SH_RES012);
if (SH_RES004 = .) and (RESMISS <= 5) then SH_RES004 = mean(of SH_RES001-SH_RES012);
if (SH_RES005 = .) and (RESMISS <= 5) then SH_RES005 = mean(of SH_RES001-SH_RES012);
if (SH_RES006 = .) and (RESMISS <= 5) then SH_RES006 = mean(of SH_RES001-SH_RES012);
if (SH_RES007 = .) and (RESMISS <= 5) then SH_RES007 = mean(of SH_RES001-SH_RES012);
if (SH_RES008 = .) and (RESMISS <= 5) then SH_RES008 = mean(of SH_RES001-SH_RES012);
if (SH_RES009 = .) and (RESMISS <= 5) then SH_RES009 = mean(of SH_RES001-SH_RES012);
if (SH_RES010 = .) and (RESMISS <= 5) then SH_RES010 = mean(of SH_RES001-SH_RES012);
if (SH_RES011 = .) and (RESMISS <= 5) then SH_RES011 = mean(of SH_RES001-SH_RES012);
if (SH_RES012 = .) and (RESMISS <= 5) then SH_RES012 = mean(of SH_RES001-SH_RES012);

/*score total*/
SH_RESTP = SH_RES001 + SH_RES002 + SH_RES003 + SH_RES004 + SH_RES005 + SH_RES006 + SH_RES007 + SH_RES008 + SH_RES009 + SH_RES010 + SH_RES011 + SH_RES012;

/*creation des deux indicateurs*/
SH_RESTS_1 = 0;
if SH_RESTP = . then SH_RESTS_1 = .;
else if SH_RESTP >= 45 then SH_RESTS_1 = 1;
label SH_RESTS_1 = "&students6 have a high or moderate level of resilience";

SH_RESTS_2 = SH_RESTP;
label SH_RESTS_2 = "Average resilience score of students who are in grades 6 to 12";

/*indicateur Q34 - SH_DEP01_1*/
if SH_DEP01 = 1 then SH_DEP01_1 = 1;
if SH_DEP01 = 0 then SH_DEP01_1 = 0;
label SH_DEP01_1 = "&students6 report having felt so sad or hopeless almost every day for two weeks or more in a row that they stopped doing some usual activities in the last 12 months";

/*indicateur Q35 - SH_BUVAO_1 SH_BUV01_1 SH_BUV02_1 SH_BUV03_1 SH_BUV04_1 SH_BUV05_1 SH_BUV06_1 SH_BUV07_1*/
if 		(SH_BUV01 = .) or
(SH_BUV02 = .) or
(SH_BUV03 = .) or
(SH_BUV04 = .) or
(SH_BUV05 = .) or
(SH_BUV06 = .) or
(SH_BUV07 = .) then SH_BUVAO_1 = .;
else if (SH_BUV01 = 1) and
(SH_BUV02 = 1) and
(SH_BUV03 = 1) and
(SH_BUV04 = 1) and
(SH_BUV05 = 1) and
(SH_BUV06 = 1) and
(SH_BUV07 = 1) then SH_BUVAO_1 = 0;
else SH_BUVAO_1 = 1;
label SH_BUVAO_1 = "&students6 report having been bullied at school in the past couple of months";

if SH_BUV01 = 1 then SH_BUV01_1 = 0;
if SH_BUV01 = 2 then SH_BUV01_1 = 1;
if SH_BUV01 = 3 then SH_BUV01_1 = 1;
if SH_BUV01 = 4 then SH_BUV01_1 = 1;
if SH_BUV01 = 5 then SH_BUV01_1 = 1;
label SH_BUV01_1 = "&students6 report having been bullied by use of physical attacks at school in the past couple of months";

if SH_BUV02 = 1 then SH_BUV02_1 = 0;
if SH_BUV02 = 2 then SH_BUV02_1 = 1;
if SH_BUV02 = 3 then SH_BUV02_1 = 1;
if SH_BUV02 = 4 then SH_BUV02_1 = 1;
if SH_BUV02 = 5 then SH_BUV02_1 = 1;
label SH_BUV02_1 = "&students6 report having been bullied by use of verbal attacks at school in the past couple of months";

if SH_BUV03 = 1 then SH_BUV03_1 = 0;
if SH_BUV03 = 2 then SH_BUV03_1 = 1;
if SH_BUV03 = 3 then SH_BUV03_1 = 1;
if SH_BUV03 = 4 then SH_BUV03_1 = 1;
if SH_BUV03 = 5 then SH_BUV03_1 = 1;
label SH_BUV03_1 = "&students6 report having been bullied by use of cyber-attacks at school in the past couple of months";

if SH_BUV04 = 1 then SH_BUV04_1 = 0;
if SH_BUV04 = 2 then SH_BUV04_1 = 1;
if SH_BUV04 = 3 then SH_BUV04_1 = 1;
if SH_BUV04 = 4 then SH_BUV04_1 = 1;
if SH_BUV04 = 5 then SH_BUV04_1 = 1;
label SH_BUV04_1 = "&students6 report having been bullied by someone stealing or damading their things at school in the past couple of months";

if SH_BUV05 = 1 then SH_BUV05_1 = 0;
if SH_BUV05 = 2 then SH_BUV05_1 = 1;
if SH_BUV05 = 3 then SH_BUV05_1 = 1;
if SH_BUV05 = 4 then SH_BUV05_1 = 1;
if SH_BUV05 = 5 then SH_BUV05_1 = 1;
label SH_BUV05_1 = "&students6 report having been bullied by exclusion at school in the past couple of months";

if SH_BUV06 = 1 then SH_BUV06_1 = 0;
if SH_BUV06 = 2 then SH_BUV06_1 = 1;
if SH_BUV06 = 3 then SH_BUV06_1 = 1;
if SH_BUV06 = 4 then SH_BUV06_1 = 1;
if SH_BUV06 = 5 then SH_BUV06_1 = 1;
label SH_BUV06_1 = "&students6 report having been bullied with mean comments about their race/religion/personal features at school in the past couple of months";

if SH_BUV07 = 1 then SH_BUV07_1 = 0;
if SH_BUV07 = 2 then SH_BUV07_1 = 1;
if SH_BUV07 = 3 then SH_BUV07_1 = 1;
if SH_BUV07 = 4 then SH_BUV07_1 = 1;
if SH_BUV07 = 5 then SH_BUV07_1 = 1;
label SH_BUV07_1 = "&students6 report having been bullied by use of sexual jokes, comment, or gestures at school in the past couple of months";

/*indicateur Q36 - SH_BUPAO_1 SH_BUP01_1 SH_BUP02_1 SH_BUP03_1 SH_BUP04_1 SH_BUP05_1 SH_BUP06_1 SH_BUP07_1*/
if 		(SH_BUP01 = .) or
(SH_BUP02 = .) or
(SH_BUP03 = .) or
(SH_BUP04 = .) or
(SH_BUP05 = .) or
(SH_BUP06 = .) or
(SH_BUP07 = .) then SH_BUPAO_1 = .;
else if (SH_BUP01 = 1) and
(SH_BUP02 = 1) and
(SH_BUP03 = 1) and
(SH_BUP04 = 1) and
(SH_BUP05 = 1) and
(SH_BUP06 = 1) and
(SH_BUP07 = 1) then SH_BUPAO_1 = 0;
else SH_BUPAO_1 = 1;
label SH_BUPAO_1 = "&students6 report having bullied at school in the past couple of months";

if SH_BUP01 = 1 then SH_BUP01_1 = 0;
if SH_BUP01 = 2 then SH_BUP01_1 = 1;
if SH_BUP01 = 3 then SH_BUP01_1 = 1;
if SH_BUP01 = 4 then SH_BUP01_1 = 1;
if SH_BUP01 = 5 then SH_BUP01_1 = 1;
label SH_BUP01_1 = "&students6 report having bullied another student, by use of physical attacks, at school in the past couple of months";

if SH_BUP02 = 1 then SH_BUP02_1 = 0;
if SH_BUP02 = 2 then SH_BUP02_1 = 1;
if SH_BUP02 = 3 then SH_BUP02_1 = 1;
if SH_BUP02 = 4 then SH_BUP02_1 = 1;
if SH_BUP02 = 5 then SH_BUP02_1 = 1;
label SH_BUP02_1 = "&students6 report having bullied another student, by use of verbal attacks, at school in the past couple of months";

if SH_BUP03 = 1 then SH_BUP03_1 = 0;
if SH_BUP03 = 2 then SH_BUP03_1 = 1;
if SH_BUP03 = 3 then SH_BUP03_1 = 1;
if SH_BUP03 = 4 then SH_BUP03_1 = 1;
if SH_BUP03 = 5 then SH_BUP03_1 = 1;
label SH_BUP03_1 = "&students6 report having bullied another student, by use of cyber-attacks, at school in the past couple of months";

if SH_BUP04 = 1 then SH_BUP04_1 = 0;
if SH_BUP04 = 2 then SH_BUP04_1 = 1;
if SH_BUP04 = 3 then SH_BUP04_1 = 1;
if SH_BUP04 = 4 then SH_BUP04_1 = 1;
if SH_BUP04 = 5 then SH_BUP04_1 = 1;
label SH_BUP04_1 = "&students6 report having bullied another student by stealing or damading their things at school in the past couple of months";

if SH_BUP05 = 1 then SH_BUP05_1 = 0;
if SH_BUP05 = 2 then SH_BUP05_1 = 1;
if SH_BUP05 = 3 then SH_BUP05_1 = 1;
if SH_BUP05 = 4 then SH_BUP05_1 = 1;
if SH_BUP05 = 5 then SH_BUP05_1 = 1;
label SH_BUP05_1 = "&students6 report having bullied another student by exclusion at school in the past couple of months";

if SH_BUP06 = 1 then SH_BUP06_1 = 0;
if SH_BUP06 = 2 then SH_BUP06_1 = 1;
if SH_BUP06 = 3 then SH_BUP06_1 = 1;
if SH_BUP06 = 4 then SH_BUP06_1 = 1;
if SH_BUP06 = 5 then SH_BUP06_1 = 1;
label SH_BUP06_1 = "&students6 report having bullied another student with mean comments about their race/religion/personal features at school in the past couple of months";

if SH_BUP07 = 1 then SH_BUP07_1 = 0;
if SH_BUP07 = 2 then SH_BUP07_1 = 1;
if SH_BUP07 = 3 then SH_BUP07_1 = 1;
if SH_BUP07 = 4 then SH_BUP07_1 = 1;
if SH_BUP07 = 5 then SH_BUP07_1 = 1;
label SH_BUP07_1 = "&students6 report having bullied another student by use of sexual jokes, comment, or gestures at school in the past couple of months";

/*indicateur Q37 - SH_BULII_1 SH_BULTP_1 SH_BULTT_1 SH_BULTR_1 SH_BULTA_1 SH_BULJB_1*/
if (SH_BULHS = 0) and
(SH_BULII = 0) and
(SH_BULTP = 0) and
(SH_BULTT = 0) and
(SH_BULTR = 0) and
(SH_BULTA = 0) and
(SH_BULTF = 0) and
(SH_BULTS = 0) and
(SH_BULAH = 0) and
(SH_BULLH = 0) and
(SH_BULSW = 0) and
(SH_BULMJ = 0) and
(SH_BULJB = 0) and
(SH_BULGS = 0) and
(SH_BULSU = 0) and
(SH_BULGB = 0) and
(SH_BULOT = 0) then SH_BULII_1 = .;
else if (SH_BULHS = 1) then SH_BULII_1 = .;
else if (SH_BULII = 1) then SH_BULII_1 = 1;
else if (SH_BULII = 0) then SH_BULII_1 = 0;
label SH_BULII_1 = "&students6 report having ignored the bullying last time they saw or heard it";

if (SH_BULHS = 0) and
(SH_BULII = 0) and
(SH_BULTP = 0) and
(SH_BULTT = 0) and
(SH_BULTR = 0) and
(SH_BULTA = 0) and
(SH_BULTF = 0) and
(SH_BULTS = 0) and
(SH_BULAH = 0) and
(SH_BULLH = 0) and
(SH_BULSW = 0) and
(SH_BULMJ = 0) and
(SH_BULJB = 0) and
(SH_BULGS = 0) and
(SH_BULSU = 0) and
(SH_BULGB = 0) and
(SH_BULOT = 0) then SH_BULTP_1 = .;
else if (SH_BULHS = 1) then SH_BULTP_1 = .;
else if (SH_BULTP = 1) then SH_BULTP_1 = 1;
else if (SH_BULTP = 0) then SH_BULTP_1 = 0;
label SH_BULTP_1 = "&students6 report having told their parents about the bullying last time they saw or heard it";

if (SH_BULHS = 0) and
(SH_BULII = 0) and
(SH_BULTP = 0) and
(SH_BULTT = 0) and
(SH_BULTR = 0) and
(SH_BULTA = 0) and
(SH_BULTF = 0) and
(SH_BULTS = 0) and
(SH_BULAH = 0) and
(SH_BULLH = 0) and
(SH_BULSW = 0) and
(SH_BULMJ = 0) and
(SH_BULJB = 0) and
(SH_BULGS = 0) and
(SH_BULSU = 0) and
(SH_BULGB = 0) and
(SH_BULOT = 0) then SH_BULTT_1 = .;
else if (SH_BULHS = 1) then SH_BULTT_1 = .;
else if (SH_BULTT = 1) then SH_BULTT_1 = 1;
else if (SH_BULTT = 0) then SH_BULTT_1 = 0;
label SH_BULTT_1 = "&students6 report having told their teachers about the bullying last time they saw or heard it";

if (SH_BULHS = 0) and
(SH_BULII = 0) and
(SH_BULTP = 0) and
(SH_BULTT = 0) and
(SH_BULTR = 0) and
(SH_BULTA = 0) and
(SH_BULTF = 0) and
(SH_BULTS = 0) and
(SH_BULAH = 0) and
(SH_BULLH = 0) and
(SH_BULSW = 0) and
(SH_BULMJ = 0) and
(SH_BULJB = 0) and
(SH_BULGS = 0) and
(SH_BULSU = 0) and
(SH_BULGB = 0) and
(SH_BULOT = 0) then SH_BULTR_1 = .;
else if (SH_BULHS = 1) then SH_BULTR_1 = .;
else if (SH_BULTR = 1) then SH_BULTR_1 = 1;
else if (SH_BULTR = 0) then SH_BULTR_1 = 0;
label SH_BULTR_1 = "&students6 report having told their principal or vice-principal about the bullying last time they saw or heard it";

if (SH_BULHS = 0) and
(SH_BULII = 0) and
(SH_BULTP = 0) and
(SH_BULTT = 0) and
(SH_BULTR = 0) and
(SH_BULTA = 0) and
(SH_BULTF = 0) and
(SH_BULTS = 0) and
(SH_BULAH = 0) and
(SH_BULLH = 0) and
(SH_BULSW = 0) and
(SH_BULMJ = 0) and
(SH_BULJB = 0) and
(SH_BULGS = 0) and
(SH_BULSU = 0) and
(SH_BULGB = 0) and
(SH_BULOT = 0) then SH_BULTA_1 = .;
else if (SH_BULHS = 1) then SH_BULTA_1 = .;
else if (SH_BULTA = 1) then SH_BULTA_1 = 1;
else if (SH_BULTA = 0) then SH_BULTA_1 = 0;
label SH_BULTA_1 = "&students6 report having told an adult at their school about the bullying last time they saw or heard it";

if (SH_BULHS = 0) and
(SH_BULII = 0) and
(SH_BULTP = 0) and
(SH_BULTT = 0) and
(SH_BULTR = 0) and
(SH_BULTA = 0) and
(SH_BULTF = 0) and
(SH_BULTS = 0) and
(SH_BULAH = 0) and
(SH_BULLH = 0) and
(SH_BULSW = 0) and
(SH_BULMJ = 0) and
(SH_BULJB = 0) and
(SH_BULGS = 0) and
(SH_BULSU = 0) and
(SH_BULGB = 0) and
(SH_BULOT = 0) then SH_BULJB_1 = .;
else if (SH_BULHS = 1) then SH_BULJB_1 = .;
else if (SH_BULJB = 1) then SH_BULJB_1 = 1;
else if (SH_BULJB = 0) then SH_BULJB_1 = 0;
label SH_BULJB_1 = "&students6 report having joined in the bullying last time they saw or heard it";

/*indicateur Q38 - SH_BUL01*/
if SH_BUL01 = 1 then SH_BUL01_1 = 0;
if SH_BUL01 = 2 then SH_BUL01_1 = 0;
if SH_BUL01 = 3 then SH_BUL01_1 = 1;
if SH_BUL01 = 4 then SH_BUL01_1 = 1;
label SH_BUL01_1 = "&students6 report that if a student complains to an adult at school about bullying, something is Often or Always done about it";

/*indicateur Q39 - SH_OPPTS SH_OPP01_1 SH_OPP02_1 SH_OPP03_1 SH_OPP04_1 SH_OPP05_1 SH_OPP06_1 SH_OPP07_1 SH_OPPTS_1*/
if SH_OPP01 = 1 then SH_OPP01_1 = 0;
if SH_OPP01 = 2 then SH_OPP01_1 = 0;
if SH_OPP01 = 3 then SH_OPP01_1 = 1;
if SH_OPP01 = 4 then SH_OPP01_1 = 1;
if SH_OPP01 = 5 then SH_OPP01_1 = 1;
if SH_OPP01 = 6 then SH_OPP01_1 = 1;
label SH_OPP01_1 = "&students6 report they cut classes or skip school";

if SH_OPP02 = 1 then SH_OPP02_1 = 0;
if SH_OPP02 = 2 then SH_OPP02_1 = 0;
if SH_OPP02 = 3 then SH_OPP02_1 = 1;
if SH_OPP02 = 4 then SH_OPP02_1 = 1;
if SH_OPP02 = 5 then SH_OPP02_1 = 1;
if SH_OPP02 = 6 then SH_OPP02_1 = 1;
label SH_OPP02_1 = "&students6 report they make other people do what they want";

if SH_OPP03 = 1 then SH_OPP03_1 = 0;
if SH_OPP03 = 2 then SH_OPP03_1 = 0;
if SH_OPP03 = 3 then SH_OPP03_1 = 1;
if SH_OPP03 = 4 then SH_OPP03_1 = 1;
if SH_OPP03 = 5 then SH_OPP03_1 = 1;
if SH_OPP03 = 6 then SH_OPP03_1 = 1;
label SH_OPP03_1 = "&students6 report they disobey their parents";

if SH_OPP04 = 1 then SH_OPP04_1 = 0;
if SH_OPP04 = 2 then SH_OPP04_1 = 0;
if SH_OPP04 = 3 then SH_OPP04_1 = 1;
if SH_OPP04 = 4 then SH_OPP04_1 = 1;
if SH_OPP04 = 5 then SH_OPP04_1 = 1;
if SH_OPP04 = 6 then SH_OPP04_1 = 1;
label SH_OPP04_1 = "&students6 report they talk back to their teachers";

if SH_OPP05 = 1 then SH_OPP05_1 = 0;
if SH_OPP05 = 2 then SH_OPP05_1 = 0;
if SH_OPP05 = 3 then SH_OPP05_1 = 1;
if SH_OPP05 = 4 then SH_OPP05_1 = 1;
if SH_OPP05 = 5 then SH_OPP05_1 = 1;
if SH_OPP05 = 6 then SH_OPP05_1 = 1;
label SH_OPP05_1 = "&students6 report they get into fights";

if SH_OPP06 = 1 then SH_OPP06_1 = 0;
if SH_OPP06 = 2 then SH_OPP06_1 = 0;
if SH_OPP06 = 3 then SH_OPP06_1 = 1;
if SH_OPP06 = 4 then SH_OPP06_1 = 1;
if SH_OPP06 = 5 then SH_OPP06_1 = 1;
if SH_OPP06 = 6 then SH_OPP06_1 = 1;
label SH_OPP06_1 = "&students6 report they often say mean things to people to get what theyr want";

if SH_OPP07 = 1 then SH_OPP07_1 = 0;
if SH_OPP07 = 2 then SH_OPP07_1 = 0;
if SH_OPP07 = 3 then SH_OPP07_1 = 1;
if SH_OPP07 = 4 then SH_OPP07_1 = 1;
if SH_OPP07 = 5 then SH_OPP07_1 = 1;
if SH_OPP07 = 6 then SH_OPP07_1 = 1;
label SH_OPP07_1 = "&students6 report that they take things that are not theirs from home, school, or elsewhere";

/*compte le nombre de missing pour les variables SH_OPP01-SH_OPP07 et creation dune nouvelle variable avec le nombre de miss (OPPMISS)*/
array OPP(7) SH_OPP01-SH_OPP07;
OPPMISS = cmiss(of OPP [*]);

/*creation d'une variable temporaire*/
SH_OPP001 = SH_OPP01;
SH_OPP002 = SH_OPP02;
SH_OPP003 = SH_OPP03;
SH_OPP004 = SH_OPP04;
SH_OPP005 = SH_OPP05;
SH_OPP006 = SH_OPP06;
SH_OPP007 = SH_OPP07;

/*remplacement des donnees manquantes (si moins que 4 manquantes) par la moyenne du sujet au score total*/
if (SH_OPP001 = .) and (OPPMISS <= 3) then SH_OPP001 = mean(of SH_OPP001-SH_OPP007);
if (SH_OPP002 = .) and (OPPMISS <= 3) then SH_OPP002 = mean(of SH_OPP001-SH_OPP007);
if (SH_OPP003 = .) and (OPPMISS <= 3) then SH_OPP003 = mean(of SH_OPP001-SH_OPP007);
if (SH_OPP004 = .) and (OPPMISS <= 3) then SH_OPP004 = mean(of SH_OPP001-SH_OPP007);
if (SH_OPP005 = .) and (OPPMISS <= 3) then SH_OPP005 = mean(of SH_OPP001-SH_OPP007);
if (SH_OPP006 = .) and (OPPMISS <= 3) then SH_OPP006 = mean(of SH_OPP001-SH_OPP007);
if (SH_OPP007 = .) and (OPPMISS <= 3) then SH_OPP007 = mean(of SH_OPP001-SH_OPP007);

/*score total*/
SH_OPPTP = SH_OPP001 + SH_OPP002 + SH_OPP003 + SH_OPP004 + SH_OPP005 + SH_OPP006 + SH_OPP007;

SH_OPPTS_1 = 0;
if SH_OPPTP = . then SH_OPPTS_1 = .;
else if SH_OPPTP >= 14 then SH_OPPTS_1 = 1;
label SH_OPPTS_1 = "&students6 have a high level of oppositional behaviours";

/*indicateur Q40 - SH_ANX01_1*/
if SH_ANX01 = 1 then SH_ANX01_1 = 1;
if SH_ANX01 = 0 then SH_ANX01_1 = 0;
label SH_ANX01_1 = "&students6 report having felt nervous, anxious or on edge or having been unable to stop or control worrying almost every day for two weeks or more in a row that they stopped doing some usual activities in the last 12 months";

/*indicateur Q41 - SH_LIN01_1 SH_LIN01_2 SH_LIN01_3*/
if SH_LIN01 = 0 then SH_LIN01_1 = 1;
if SH_LIN01 = 1 then SH_LIN01_1 = 0;
if SH_LIN01 = 2 then SH_LIN01_1 = 0;
label SH_LIN01_1 = "&students6 report that they are not aware of the LINK program";

if SH_LIN01 = 0 then SH_LIN01_2 = 0;
if SH_LIN01 = 1 then SH_LIN01_2 = 1;
if SH_LIN01 = 2 then SH_LIN01_2 = 0;
label SH_LIN01_2 = "&students6 report being aware of the LINK program but never having used it";

if SH_LIN01 = 0 then SH_LIN01_3 = 0;
if SH_LIN01 = 1 then SH_LIN01_3 = 0;
if SH_LIN01 = 2 then SH_LIN01_3 = 1;
label SH_LIN01_3 = "&students6 report being aware of the LINK program and having used it";

/*indicateur Q42 - SH_SMO01_1 SH_SMO01_2 SH_SMO01_3 SH_SMO01_4 SH_SMO01_5 SH_SMO01_6 SH_SMO01_7 SH_SMO01_8 SH_SMO01_9*/
if SH_SMO01 = 1 then SH_SMO01_1 = 1;
if SH_SMO01 = 0 then SH_SMO01_1 = 0;
label SH_SMO01_1 = "&students6 have tried cigarette smoking, even just a few puffs";

if SH_SMO01 = 1 then SH_SMO01_2 = 0;
if SH_SMO01 = 0 then SH_SMO01_2 = 1;
label SH_SMO01_2 = 'Students in grade 12 who have NEVER tried cigarette smoking, even just a few puffs';

if (SH_SMO01 = .) or (SH_GRADE ne 6) then SH_SMO01_3 = .;
else if SH_SMO01 = 1 then SH_SMO01_3 = 1;
else if SH_SMO01 = 0 then SH_SMO01_3 = 0;
label SH_SMO01_3 = "Students6 in grades 6 who have tried cigarette smoking, even just a few puffs";

if (SH_SMO01 = .) or (SH_GRADE ne 7) then SH_SMO01_4 = .;
else if SH_SMO01 = 1 then SH_SMO01_4 = 1;
else if SH_SMO01 = 0 then SH_SMO01_4 = 0;
label SH_SMO01_4 = "Students6 in grades 7 who have tried cigarette smoking, even just a few puffs";

if (SH_SMO01 = .) or (SH_GRADE ne 8) then SH_SMO01_5 = .;
else if SH_SMO01 = 1 then SH_SMO01_5 = 1;
else if SH_SMO01 = 0 then SH_SMO01_5 = 0;
label SH_SMO01_5 = "Students6 in grades 8 who have tried cigarette smoking, even just a few puffs";

if (SH_SMO01 = .) or (SH_GRADE ne 9) then SH_SMO01_6 = .;
else if SH_SMO01 = 1 then SH_SMO01_6 = 1;
else if SH_SMO01 = 0 then SH_SMO01_6 = 0;
label SH_SMO01_6 = "Students6 in grades 9 who have tried cigarette smoking, even just a few puffs";

if (SH_SMO01 = .) or (SH_GRADE ne 10) then SH_SMO01_7 = .;
else if SH_SMO01 = 1 then SH_SMO01_7 = 1;
else if SH_SMO01 = 0 then SH_SMO01_7 = 0;
label SH_SMO01_7 = "Students6 in grades 10 who have tried cigarette smoking, even just a few puffs";

if (SH_SMO01 = .) or (SH_GRADE ne 11) then SH_SMO01_8 = .;
else if SH_SMO01 = 1 then SH_SMO01_8 = 1;
else if SH_SMO01 = 0 then SH_SMO01_8 = 0;
label SH_SMO01_8 = "Students6 in grades 11 who have tried cigarette smoking, even just a few puffs";

if (SH_SMO01 = .) or (SH_GRADE ne 12) then SH_SMO01_9 = .;
else if SH_SMO01 = 1 then SH_SMO01_9 = 1;
else if SH_SMO01 = 0 then SH_SMO01_9 = 0;
label SH_SMO01_9 = "Students6 in grades 12 who have tried cigarette smoking, even just a few puffs";

/*indicateur Q42, Q43, Q44, Q45 - SH_SMOSU_1*/
if SH_SMO01 = 0 then TEMPa = 1;
else TEMPa=0;
if (SH_SMO02 = .) and (SH_SMO03 = .) and (SH_SMO04 = .) then TEMPb = 0;
else TEMPb=1;
if (TEMPa = 0) or (TEMPb = 0) then SH_SMOSU_1 = .;
else if (SH_SMO02 = 1) and (SH_SMO03 = 1) and (SH_SMO04 = 1) then SH_SMOSU_1 = 0;
else SH_SMOSU_1 = 1;
label SH_SMOSU_1 = "&students6 are sussceptible to smoking (among those who have never tried it)";

/*indicateur Q46a - SH_ALC01*/
if (SH_ALC01 = .) or (SH_ALC01 = 0) or (SH_GRADE ne 12) then SH_ALC01_1 = .;
else SH_ALC01_1 = SH_ALC01 + 9;
label SH_ALC01_1 = "Average age at which students in grade 12 drank alcohol (more than a sip) for the first time ";

/*indicateur Q46c - SH_SMO05_1*/
if (SH_SMO05 = .) or (SH_SMO05 = 0) or (SH_GRADE ne 12) then SH_SMO05_1 = .;
else SH_SMO05_1 = SH_SMO05 + 9;
label SH_SMO05_1 = "Average age at which students in grade 12 smoked a cigarette (more than a puff) for the first time";

/*indicateur Q46d - SH_MAR01_1*/
if (SH_MAR01 = .) or (SH_MAR01 = 0) or (SH_GRADE ne 12) then SH_MAR01_1 = .;
else SH_MAR01_1 = SH_MAR01 + 9;
label SH_MAR01_1 = "Average age at which students in grade 12 first used marijuana";

/*Indicateurs Q47 - SH_SMO06_1 SH_SMO06_2 SH_SMO06_3 SH_SMO06_4*/
if SH_SMO06 = 1 then SH_SMO06_1 = 1;
if SH_SMO06 = 2 then SH_SMO06_1 = 0;
if SH_SMO06 = 3 then SH_SMO06_1 = 0;
if SH_SMO06 = 4 then SH_SMO06_1 = 0;
label SH_SMO06_1 = "&students6 report that no one is allowed to smoke in their home";

if SH_SMO06 = 1 then SH_SMO06_2 = 0;
if SH_SMO06 = 2 then SH_SMO06_2 = 1;
if SH_SMO06 = 3 then SH_SMO06_2 = 0;
if SH_SMO06 = 4 then SH_SMO06_2 = 0;
label SH_SMO06_2 = "&students6 report that only special guests are allowed to smoke in their home";

if SH_SMO06 = 1 then SH_SMO06_3 = 0;
if SH_SMO06 = 2 then SH_SMO06_3 = 0;
if SH_SMO06 = 3 then SH_SMO06_3 = 1;
if SH_SMO06 = 4 then SH_SMO06_3 = 0;
label SH_SMO06_3 = "&students6 report that people are allowed to smoke only in certain areas in their home";

if SH_SMO06 = 1 then SH_SMO06_4 = 0;
if SH_SMO06 = 2 then SH_SMO06_4 = 0;
if SH_SMO06 = 3 then SH_SMO06_4 = 0;
if SH_SMO06 = 4 then SH_SMO06_4 = 1;
label SH_SMO06_4 = "&students6 report that people are allowed to smoke anywhere in their home";

/*Indicateurs Q48 - SH_SMO07_1 SH_SMO07_2*/
if SH_SMO07 = 1 then SH_SMO07_1 = 1;
if SH_SMO07 = 0 then SH_SMO07_1 = 0;
if SH_SMO07 = 3 then SH_SMO07_1 = .;
label SH_SMO07_1 = "&students6 report their school has a clear set of rules about smoking for students to follow";

if SH_SMO07 = 1 then SH_SMO07_2 = 0;
if SH_SMO07 = 0 then SH_SMO07_2 = 0;
if SH_SMO07 = 3 then SH_SMO07_2 = 1;
label SH_SMO07_2 = "&students6 report they don't know whether their school has a clear set of rules about smoking for students to follow";

/*Indicateurs Q48 et Q49 - SH_SMO08_1*/
if (SH_SMO07 = .) or
(SH_SMO07 = 3) or
(SH_SMO08 = .) then SH_SMO08_1 = .;
else if SH_SMO08 = 1 then SH_SMO08_1 = 1;
else if SH_SMO08 = 0 then SH_SMO08_1 = 0;
else if SH_SMO08 = 3 then SH_SMO08_1 = 0;
label SH_SMO08_1 = "&students6 report that students caught breaking the smoking rules at their school get into trouble";

/*indicateurs Q50 - SH_SMOLC_1 SH_SMOSC_1 SH_SMORC_1 SH_SMOSB_1 SH_SMOST_1 SH_SMONP_1 SH_SMOWP_1 SH_SMOBW_1 SH_SMOEC_1 SH_SMOAS_1*/
if SH_SMOLC = 1 then SH_SMOLC_1 = 1;
if SH_SMOLC = 0 then SH_SMOLC_1 = 0;
label SH_SMOLC_1 = "&students6 report having ever tried smoking little cigars or cigarillos (plain or flavoured)";

if SH_SMOSC = 1 then SH_SMOSC_1 = 1;
if SH_SMOSC = 0 then SH_SMOSC_1 = 0;
label SH_SMOSC_1 = "&students6 report having ever tried smoking cigars (not including little cigars or cigarillos, plain or flavoured)";

if SH_SMORC = 1 then SH_SMORC_1 = 1;
if SH_SMORC = 0 then SH_SMORC_1 = 0;
label SH_SMORC_1 = "&students6 report having ever tried smoking roll-your-own cigarettes (tobacco only, in rolling papers)";

if SH_SMOSB = 1 then SH_SMOSB_1 = 1;
if SH_SMOSB = 0 then SH_SMOSB_1 = 0;
label SH_SMOSB_1 = "&students6 report having ever tried smoking bidis (little cigarettes hand-rolled in leaves, tied with string at the ends, and may come in different flavours)";

if SH_SMOST = 1 then SH_SMOST_1 = 1;
if SH_SMOST = 0 then SH_SMOST_1 = 0;
label SH_SMOST_1 = "&students6 report having ever tried using smokeless tobacco (chewing tobacco, pinch, snuff, or snus)";

if SH_SMONP = 1 then SH_SMONP_1 = 1;
if SH_SMONP = 0 then SH_SMONP_1 = 0;
label SH_SMONP_1 = "&students6 report having ever tried using nicotine patches, nicotine gum, nicotine lozenges, or nicotine inhalers";

if SH_SMOWP = 1 then SH_SMOWP_1 = 1;
if SH_SMOWP = 0 then SH_SMOWP_1 = 0;
label SH_SMOWP_1 = "&students6 report having ever tried using a water-pipe (hookah) to smoke sheesha (herbal or tobacco)";

if SH_SMOBW = 1 then SH_SMOBW_1 = 1;
if SH_SMOBW = 0 then SH_SMOBW_1 = 0;
label SH_SMOBW_1 = "&students6 report having ever tried using blunt wraps (a tube made of tobacco used to roll cigarette tobacco)";

if SH_SMOEC = 1 then SH_SMOEC_1 = 1;
if SH_SMOEC = 0 then SH_SMOEC_1 = 0;
label SH_SMOEC_1 = "&students6 report having ever tried using e-cigarettes (electronic cigarettes, vape)";

if (SH_SMOLC = 1) or
(SH_SMOSC = 1) or
(SH_SMORC = 1) or
(SH_SMOSB = 1) or
(SH_SMOST = 1) or
(SH_SMONP = 1) or
(SH_SMOWP = 1) or
(SH_SMOBW = 1) or
(SH_SMOEC = 1) then SH_SMOAS_1 = 1;
else  SH_SMOAS_1 = 0;
label SH_SMOAS_1 = "&students6 report having ever tried any alternative smoking product";

/*indicateur Q51 - SH_SMO09_1 SH_SMO09_2*/
if SH_SMO09 = 1 then SH_SMO09_1 = 0;
if SH_SMO09 = 2 then SH_SMO09_1 = 1;
if SH_SMO09 = 3 then SH_SMO09_1 = 1;
if SH_SMO09 = 4 then SH_SMO09_1 = 1;
label SH_SMO09_1 = "&students6 report smoking, in any amount, at present";

if SH_SMO09 = 1 then SH_SMO09_2 = 0;
if SH_SMO09 = 2 then SH_SMO09_2 = 0;
if SH_SMO09 = 3 then SH_SMO09_2 = 0;
if SH_SMO09 = 4 then SH_SMO09_2 = 1;
label SH_SMO09_2 = "&students6 report smoking every day at present";

/*Indicateur - Q52 SH_SMO10_1 SH_SMO11_1 SH_SMO12_1*/
if SH_SMO10 = 0 then SH_SMO10_1 = 0;
if SH_SMO10 = 1 then SH_SMO10_1 = 1;
if SH_SMO10 = 2 then SH_SMO10_1 = 1;
if SH_SMO10 = 3 then SH_SMO10_1 = 1;
if SH_SMO10 = 4 then SH_SMO10_1 = .;
if SH_SMO10 = 5 then SH_SMO10_1 = .;
label SH_SMO10_1 = "&students6 report having at least one parent, step-parent or guardian smoke cigarettes";

if SH_SMO11 = 0 then SH_SMO11_1 = 0;
if SH_SMO11 = 1 then SH_SMO11_1 = 1;
if SH_SMO11 = 2 then SH_SMO11_1 = 1;
if SH_SMO11 = 3 then SH_SMO11_1 = 1;
if SH_SMO11 = 4 then SH_SMO11_1 = .;
if SH_SMO11 = 5 then SH_SMO11_1 = .;
label SH_SMO11_1 = "&students6 report having at least one sibling smoke cigarettes";

if SH_SMO12 = 0 then SH_SMO12_1 = 0;
if SH_SMO12 = 1 then SH_SMO12_1 = 1;
if SH_SMO12 = 2 then SH_SMO12_1 = 1;
if SH_SMO12 = 3 then SH_SMO12_1 = 1;
if SH_SMO12 = 4 then SH_SMO12_1 = .;
if SH_SMO12 = 5 then SH_SMO12_1 = .;
label SH_SMO12_1 = "&students6 report having at least one friend smoke cigarettes";

/*Indicateur Q53 - SH_SMO13_1*/
if SH_SMO13 = 0 then SH_SMO13_1 = 0;
if SH_SMO13 = 1 then SH_SMO13_1 = 1;
if SH_SMO13 = 2 then SH_SMO13_1 = 1;
if SH_SMO13 = 3 then SH_SMO13_1 = 1;
if SH_SMO13 = 4 then SH_SMO13_1 = 1;
if SH_SMO13 = 5 then SH_SMO13_1 = 1;
label SH_SMO13_1 = "&students6 have at least one person smoke inside their home every day or almost every day";

/**************WARNING*************/
/*Indicateur Q54 - SH_SMO14_1*/
if SH_SMO14 = 0 then SH_SMO14_1 = 0;
if SH_SMO14 = 1 then SH_SMO14_1 = 0;
if SH_SMO14 = 2 then SH_SMO14_1 = 1;
if SH_SMO14 = 3 then SH_SMO14_1 = 1;
if SH_SMO14 = 4 then SH_SMO14_1 = 1;
if SH_SMO14 = 5 then SH_SMO14_1 = 1;
if SH_SMO14 = 6 then SH_SMO14_1 = .;
if SH_SMO14 = 7 then SH_SMO14_1 = .;
label SH_SMO14_1 = "&students6 report riding in a car with someone who was smoking cigarettes during the last 7 days.";

/*indicateurs Q55 - SH_ALC03_1 SH_ALC03_2*/
if SH_ALC03 = 1  then SH_ALC03_1 = 0;
if SH_ALC03 = 2  then SH_ALC03_1 = 0;
if SH_ALC03 = 3  then SH_ALC03_1 = 0;
if SH_ALC03 = 4  then SH_ALC03_1 = 0;
if SH_ALC03 = 5  then SH_ALC03_1 = 1;
if SH_ALC03 = 6  then SH_ALC03_1 = 1;
if SH_ALC03 = 7  then SH_ALC03_1 = 1;
if SH_ALC03 = 8  then SH_ALC03_1 = 1;
if SH_ALC03 = 9  then SH_ALC03_1 = 1;
if SH_ALC03 = 10 then SH_ALC03_1 = 1;
if SH_ALC03 = 11 then SH_ALC03_1 = .;
label SH_ALC03_1 = "&students7 report having had a drink of alcohol once a month or more in the last 12 months";

if SH_ALC03 = 1  then SH_ALC03_2 = 0;
if SH_ALC03 = 2  then SH_ALC03_2 = 0;
if SH_ALC03 = 3  then SH_ALC03_2 = 0;
if SH_ALC03 = 4  then SH_ALC03_2 = 1;
if SH_ALC03 = 5  then SH_ALC03_2 = 1;
if SH_ALC03 = 6  then SH_ALC03_2 = 1;
if SH_ALC03 = 7  then SH_ALC03_2 = 1;
if SH_ALC03 = 8  then SH_ALC03_2 = 1;
if SH_ALC03 = 9  then SH_ALC03_2 = 1;
if SH_ALC03 = 10 then SH_ALC03_2 = 1;
if SH_ALC03 = 11 then SH_ALC03_2 = .;
label SH_ALC03_2 = "&students7 report having had a drink of alcohol in the last 12 months that was more than a sip";

/*indicateur Q56 - SH_ALC04_1*/
if SH_ALC04 = 1  then SH_ALC04_1 = 0;
if SH_ALC04 = 2  then SH_ALC04_1 = 0;
if SH_ALC04 = 3  then SH_ALC04_1 = 0;
if SH_ALC04 = 4  then SH_ALC04_1 = 1;
if SH_ALC04 = 5  then SH_ALC04_1 = 1;
if SH_ALC04 = 6  then SH_ALC04_1 = 1;
if SH_ALC04 = 7  then SH_ALC04_1 = 1;
if SH_ALC04 = 8  then SH_ALC04_1 = 1;
if SH_ALC04 = 9  then SH_ALC04_1 = .;
label SH_ALC04_1 = "&students7 report having had five or more drinks at one time, at least once a month, in the last 12 months";

/*indicateur Q57 - SH_MAR02_1 SH_MAR02_2 SH_MAR02_3*/
if SH_MAR02 = 1  then SH_MAR02_1 = 0;
if SH_MAR02 = 2  then SH_MAR02_1 = 1;
if SH_MAR02 = 3  then SH_MAR02_1 = 1;
if SH_MAR02 = 4  then SH_MAR02_1 = 1;
if SH_MAR02 = 5  then SH_MAR02_1 = 1;
if SH_MAR02 = 6  then SH_MAR02_1 = 1;
if SH_MAR02 = 7  then SH_MAR02_1 = 1;
if SH_MAR02 = 8  then SH_MAR02_1 = 1;
if SH_MAR02 = 9  then SH_MAR02_1 = 1;
if SH_MAR02 = 10 then SH_MAR02_1 = .;
label SH_MAR02_1 = "&students7 report having ever used marijuana or cannabis (a joint, pot, weed, hash)";

if SH_MAR02 = 1  then SH_MAR02_2 = 0;
if SH_MAR02 = 2  then SH_MAR02_2 = 0;
if SH_MAR02 = 3  then SH_MAR02_2 = 1;
if SH_MAR02 = 4  then SH_MAR02_2 = 1;
if SH_MAR02 = 5  then SH_MAR02_2 = 1;
if SH_MAR02 = 6  then SH_MAR02_2 = 1;
if SH_MAR02 = 7  then SH_MAR02_2 = 1;
if SH_MAR02 = 8  then SH_MAR02_2 = 1;
if SH_MAR02 = 9  then SH_MAR02_2 = 1;
if SH_MAR02 = 10 then SH_MAR02_2 = .;
label SH_MAR02_2 = "&students7 report having used marijuana or cannabis (a joint, pot, weed, hash) at least once in the last 12 months";

if SH_MAR02 = 1  then SH_MAR02_3 = 0;
if SH_MAR02 = 2  then SH_MAR02_3 = 0;
if SH_MAR02 = 3  then SH_MAR02_3 = 0;
if SH_MAR02 = 4  then SH_MAR02_3 = 0;
if SH_MAR02 = 5  then SH_MAR02_3 = 0;
if SH_MAR02 = 6  then SH_MAR02_3 = 0;
if SH_MAR02 = 7  then SH_MAR02_3 = 0;
if SH_MAR02 = 8  then SH_MAR02_3 = 0;
if SH_MAR02 = 9  then SH_MAR02_3 = 1;
if SH_MAR02 = 10 then SH_MAR02_3 = .;
label SH_MAR02_3 = "&students7 report having used marijuana or cannabis (a joint, pot, weed, hash) every day in the last 12 months";

/*indicateur Q58 - SH_SAF01_1*/
if SH_SAF01 = 1 then SH_SAF01_1 = 0;
if SH_SAF01 = 2 then SH_SAF01_1 = 0;
if SH_SAF01 = 3 then SH_SAF01_1 = 1;
if SH_SAF01 = 4 then SH_SAF01_1 = 1;
label SH_SAF01_1 = "&students7 drove an off-road vehicle (e.g., snowmobile, ATV, dirt bike) after drinking alcohol, using marijuana, or other illegal drugs in the last 12 months";

/*indicateur Q59 - SH_SAF02_1*/
if SH_SAF02 = 1 then SH_SAF02_1 = 0;
if SH_SAF02 = 2 then SH_SAF02_1 = 0;
if SH_SAF02 = 3 then SH_SAF02_1 = 1;
if SH_SAF02 = 4 then SH_SAF02_1 = 1;
label SH_SAF02_1 = "&students7 rode in an on-road vehicle (e.g., car, van, truck) driven by someone who had been drinking alcohol, using marijuana, or other illegal drugs in the last 12 months";

/*indicateur Q60 - SH_SAF03_1*/
if SH_SAF03 = 1 then SH_SAF03_1 = .;
if SH_SAF03 = 2 then SH_SAF03_1 = 0;
if SH_SAF03 = 3 then SH_SAF03_1 = 0;
if SH_SAF03 = 4 then SH_SAF03_1 = 0;
if SH_SAF03 = 5 then SH_SAF03_1 = 1;
label SH_SAF03_1 = "&students6 report always wearing a helmet when riding a bicycle during the past 12 months";

/*indicateur Q61 - SH_INJ01_1*/
if SH_INJ01 = 1 then SH_INJ01_1 = 1;
if SH_INJ01 = 0 then SH_INJ01_1 = 0;
label SH_INJ01_1 = "&students6 report being injured and having to be treated by a doctor or nurse during the past 12 months";

/*indicateurs Q62 - SH_SEV01_1 SH_SEV01_2 SH_SEV01_3*/
if SH_SEV01 = 1 then SH_SEV01_1 = 1;
if SH_SEV01 = 0 then SH_SEV01_1 = 0;
label SH_SEV01_1 = "&students7 report having someone ever make them do any sexual activity (e.g., kissing, oral sex, intercourse) when they didn't want to (by pressuring them with their words or actions, or by using alcohol or drugs)";

if (SH_SEV01 = .) or (SH_GEN01 ne 2) then SH_SEV01_2 = .;
else if SH_SEV01 = 1 then SH_SEV01_2 = 1;
else if SH_SEV01 = 0 then SH_SEV01_2 = 0;
label SH_SEV01_2 = "Male students in grades 7 to 12 who report having someone ever make them do any sexual activity (e.g., kissing, oral sex, intercourse) when they didn't want to (by pressuring them with their words or actions, or by using alcohol or drugs)";

if (SH_SEV01 = .) or (SH_GEN01 ne 1) then SH_SEV01_3 = .;
else if SH_SEV01 = 1 then SH_SEV01_3 = 1;
else if SH_SEV01 = 0 then SH_SEV01_3 = 0;
label SH_SEV01_3 = "Female students in grades 7 to 12 who report having someone ever make them do any sexual activity (e.g., kissing, oral sex, intercourse) when they didn't want to (by pressuring them with their words or actions, or by using alcohol or drugs)";

/*indicateurs Q63 - SH_SEV02_1 SH_SEV02_2 SH_SEV02_3*/
if SH_SEV02 = . then SH_SEV02_1 = .;
if SH_SEV02 = 1 then SH_SEV02_1 = .;
if SH_SEV02 = 2 then SH_SEV02_1 = 1;
if SH_SEV02 = 3 then SH_SEV02_1 = 0;
label SH_SEV02_1 = "&students7 report having someone they were dating or going out with physically, sexually, psychologically or emotionally hurt them during the past 12 months (among those who have dated or been going out with someone)";

if (SH_SEV02 = 1) or (SH_GEN01 ne 2) then SH_SEV02_2 = .;
else if SH_SEV02 = 2 then SH_SEV02_2 = 1;
else if SH_SEV02 = 3 then SH_SEV02_2 = 0;
label SH_SEV02_2 = "Male students in grades 7 to 12 who report having someone they were dating or going out with physically, sexually, psychologically or emotionally hurt them during the past 12 months";

if (SH_SEV02 = 1) or (SH_GEN01 ne 1) then SH_SEV02_3 = .;
else if SH_SEV02 = 2 then SH_SEV02_3 = 1;
else if SH_SEV02 = 3 then SH_SEV02_3 = 0;
label SH_SEV02_3 = "Female students in grades 7 to 12 who report having someone they were dating or going out with physically, sexually, psychologically or emotionally hurt them during the past 12 months";

/*indicateurs Q64 - SH_SEV03_1 SH_SEV03_2 SH_SEV03_3*/
if SH_SEV03 = 1 then SH_SEV03_1 = 1;
if SH_SEV03 = 0 then SH_SEV03_1 = 0;
label SH_SEV03_1 = "&students7 report knowing when they are legally able to consent to sexual activity";

if (SH_SEV03 = .) or (SH_GEN01 ne 2) then SH_SEV03_2 = .;
else if SH_SEV03 = 1 then SH_SEV03_2 = 1;
else if SH_SEV03 = 0 then SH_SEV03_2 = 0;
label SH_SEV03_2 = "Male students in grades 7 to 12 who report knowing when they are legally able to consent to sexual activity";

if (SH_SEV03 = .) or (SH_GEN01 ne 1) then SH_SEV03_3 = .;
else if SH_SEV03 = 1 then SH_SEV03_3 = 1;
else if SH_SEV03 = 0 then SH_SEV03_3 = 0;
label SH_SEV03_3 = "Female students in grades 7 to 12 who report knowing when they are legally able to consent to sexual activity";

/*indicateur Q65 - SH_SEO01_1 SH_SEO01_2 SH_SEO01_3 SH_SEO01_4 SH_SEO01_5*/
if SH_SEO01 = 1 then SH_SEO01_1 = 1;
if SH_SEO01 = 2 then SH_SEO01_1 = 0;
if SH_SEO01 = 3 then SH_SEO01_1 = 0;
if SH_SEO01 = 4 then SH_SEO01_1 = 0;
if SH_SEO01 = 5 then SH_SEO01_1 = 0;
label SH_SEO01_1 = "&students7 identify themselves as heterosexual";

if SH_SEO01 = 1 then SH_SEO01_2 = 0;
if SH_SEO01 = 2 then SH_SEO01_2 = 1;
if SH_SEO01 = 3 then SH_SEO01_2 = 0;
if SH_SEO01 = 4 then SH_SEO01_2 = 0;
if SH_SEO01 = 5 then SH_SEO01_2 = 0;
label SH_SEO01_2 = "&students7 identify themselves as gay or lesbian";

if SH_SEO01 = 1 then SH_SEO01_3 = 0;
if SH_SEO01 = 2 then SH_SEO01_3 = 0;
if SH_SEO01 = 3 then SH_SEO01_3 = 1;
if SH_SEO01 = 4 then SH_SEO01_3 = 0;
if SH_SEO01 = 5 then SH_SEO01_3 = 0;
label SH_SEO01_3 = "&students7 identify themselves as bisexual";

if SH_SEO01 = 1 then SH_SEO01_4 = 0;
if SH_SEO01 = 2 then SH_SEO01_4 = 0;
if SH_SEO01 = 3 then SH_SEO01_4 = 0;
if SH_SEO01 = 4 then SH_SEO01_4 = 1;
if SH_SEO01 = 5 then SH_SEO01_4 = 0;
label SH_SEO01_4 = "&students7 identify with a sexual orientation other than heterosexual, gay, lesbian or bisexual";

if SH_SEO01 = 1 then SH_SEO01_5 = 0;
if SH_SEO01 = 2 then SH_SEO01_5 = 0;
if SH_SEO01 = 3 then SH_SEO01_5 = 0;
if SH_SEO01 = 4 then SH_SEO01_5 = 0;
if SH_SEO01 = 5 then SH_SEO01_5 = 1;
label SH_SEO01_5 = "&students7 question their sexual orientation";

/*indicateurs Q66 - SH_VOL01_1 SH_VOL02_1 SH_VOL03_1 SH_VOL04_1 SH_VOL05_1 SH_VOLAT_1*/
if SH_VOL01 = 1 then SH_VOL01_1 = 1;
if SH_VOL01 = 0 then SH_VOL01_1 = 0;
if SH_VOL01 = 3 then SH_VOL01_1 = .;
label SH_VOL01_1 = "&students6 report supporting a cause in the last 12 months, outside of school requirements and without being paid";

if SH_VOL02 = 1 then SH_VOL02_1 = 1;
if SH_VOL02 = 0 then SH_VOL02_1 = 0;
if SH_VOL02 = 3 then SH_VOL02_1 = .;
label SH_VOL02_1 = "&students6 report having raised funds in the last 12 months, outside of school requirements and without being paid";

if SH_VOL03 = 1 then SH_VOL03_1 = 1;
if SH_VOL03 = 0 then SH_VOL03_1 = 0;
if SH_VOL03 = 3 then SH_VOL03_1 = .;
label SH_VOL03_1 = "&students6 report having helped in their community in the last 12 months, outside of school requirements and without being paid";

if SH_VOL04 = 1 then SH_VOL04_1 = 1;
if SH_VOL04 = 0 then SH_VOL04_1 = 0;
if SH_VOL04 = 3 then SH_VOL04_1 = .;
label SH_VOL04_1 = "&students6 report having helped neighbours or relatives in the last 12 months, outside of school requirements and without being paid";

if SH_VOL05 = 1 then SH_VOL05_1 = 1;
if SH_VOL05 = 0 then SH_VOL05_1 = 0;
if SH_VOL05 = 3 then SH_VOL05_1 = .;
label SH_VOL05_1 = "&students6 report having done other organized volunteer activity in the last 12 months, outside of school requirements and without being paid";

SH_VOLAT_1 = 0;
if (SH_VOL01 = 3) and (SH_VOL02 = 3) and (SH_VOL03 = 3) and (SH_VOL04 = 3) and (SH_VOL05 = 3) then SH_VOLAT_1 = .;
else if (SH_VOL01 = 1) or (SH_VOL02 = 1) or (SH_VOL03 = 1) or (SH_VOL04 = 1) or (SH_VOL05 = 1) then SH_VOLAT_1 = 1;
label SH_VOLAT_1 = "&students6 report having taken part in any type of volunteer activities outside of school requirements and without being paid in the last 12 months";

/*indicateurs Q67 - SH_SOC01_1 SH_SOC02_1 SH_SOC03_1 SH_SOC04_1 SH_SOC05_1 SH_SOC06_1 SH_SOCTS_1*/
if SH_SOC01 = 1 then SH_SOC01_1 = 0;
if SH_SOC01 = 2 then SH_SOC01_1 = 0;
if SH_SOC01 = 3 then SH_SOC01_1 = 0;
if SH_SOC01 = 4 then SH_SOC01_1 = 1;
if SH_SOC01 = 5 then SH_SOC01_1 = 1;
label SH_SOC01_1 = "&students6 Strongly Agree or Agree that people say hello and often stop to talk to each other in the street";

if SH_SOC02 = 1 then SH_SOC02_1 = 0;
if SH_SOC02 = 2 then SH_SOC02_1 = 0;
if SH_SOC02 = 3 then SH_SOC02_1 = 0;
if SH_SOC02 = 4 then SH_SOC02_1 = 1;
if SH_SOC02 = 5 then SH_SOC02_1 = 1;
label SH_SOC02_1 = "&students6  Strongly Agree or Agree that it is safe for younger children to play outside during the day";

if SH_SOC03 = 1 then SH_SOC03_1 = 0;
if SH_SOC03 = 2 then SH_SOC03_1 = 0;
if SH_SOC03 = 3 then SH_SOC03_1 = 0;
if SH_SOC03 = 4 then SH_SOC03_1 = 1;
if SH_SOC03 = 5 then SH_SOC03_1 = 1;
label SH_SOC03_1 = "&students6 Strongly Agree or Agree that you can trust people around here";

if SH_SOC04 = 1 then SH_SOC04_1 = 0;
if SH_SOC04 = 2 then SH_SOC04_1 = 0;
if SH_SOC04 = 3 then SH_SOC04_1 = 0;
if SH_SOC04 = 4 then SH_SOC04_1 = 1;
if SH_SOC04 = 5 then SH_SOC04_1 = 1;
label SH_SOC04_1 = "&students6 Strongly Agree or Agree that there are good places to spend your free time (recreation centres, parks, shopping centres)";

if SH_SOC05 = 1 then SH_SOC05_1 = 0;
if SH_SOC05 = 2 then SH_SOC05_1 = 0;
if SH_SOC05 = 3 then SH_SOC05_1 = 0;
if SH_SOC05 = 4 then SH_SOC05_1 = 1;
if SH_SOC05 = 5 then SH_SOC05_1 = 1;
label SH_SOC05_1 = "&students6 Strongly Agree or Agree that they could ask for help or a favour from neighbours";

if SH_SOC06 = 1 then SH_SOC06_1 = 0;
if SH_SOC06 = 2 then SH_SOC06_1 = 0;
if SH_SOC06 = 3 then SH_SOC06_1 = 0;
if SH_SOC06 = 4 then SH_SOC06_1 = 1;
if SH_SOC06 = 5 then SH_SOC06_1 = 1;
label SH_SOC06_1 = "&students6 Strongly Agree or Agree that most people around here would try to take advantage of you if they got the chance";

/*compte le nombre de missing pour les variables SH_SOC01-SH_SOC05 et creation dune nouvelle variable avec le nombre de miss (SOCMISS)*/
array SOC(5) SH_SOC01-SH_SOC05;
SOCMISS = cmiss(of SOC [*]);

/*creation d'une variable temporaire*/
SH_SOC001 = SH_SOC01;
SH_SOC002 = SH_SOC02;
SH_SOC003 = SH_SOC03;
SH_SOC004 = SH_SOC04;
SH_SOC005 = SH_SOC05;

/*remplacement des donnees manquantes (si moins que 6 manquantes) par la moyenne du sujet au score total*/
if (SH_SOC001 = .) and (SOCMISS <= 2) then SH_SOC001 = mean(of SH_SOC001-SH_SOC005);
if (SH_SOC002 = .) and (SOCMISS <= 2) then SH_SOC002 = mean(of SH_SOC001-SH_SOC005);
if (SH_SOC003 = .) and (SOCMISS <= 2) then SH_SOC003 = mean(of SH_SOC001-SH_SOC005);
if (SH_SOC004 = .) and (SOCMISS <= 2) then SH_SOC004 = mean(of SH_SOC001-SH_SOC005);
if (SH_SOC005 = .) and (SOCMISS <= 2) then SH_SOC005 = mean(of SH_SOC001-SH_SOC005);

/*score total*/
SH_SOCTS_1 = SH_SOC001 + SH_SOC002 + SH_SOC003 + SH_SOC004 + SH_SOC005;
label SH_SOCTS_1 = "Average community support score of students in grades 6 to 12";

/*indicateurs Q68 - SH_VAL01_1 SH_VAL02_1 SH_VAL03_1 SH_VAL04_1 SH_VAL05_1 SH_VAL06_1 SH_VAL07_1 SH_VAL08_1*/
if SH_VAL01 = 1 then SH_VAL01_1 = 0;
if SH_VAL01 = 2 then SH_VAL01_1 = 0;
if SH_VAL01 = 3 then SH_VAL01_1 = 1;
if SH_VAL01 = 4 then SH_VAL01_1 = 1;
label SH_VAL01_1 = "&students6 report that getting good grades is Very important or Important to them";

if SH_VAL02 = 1 then SH_VAL02_1 = 0;
if SH_VAL02 = 2 then SH_VAL02_1 = 0;
if SH_VAL02 = 3 then SH_VAL02_1 = 1;
if SH_VAL02 = 4 then SH_VAL02_1 = 1;
label SH_VAL02_1 = "&students6 report that making friends is Very important or Important to them";

if SH_VAL03 = 1 then SH_VAL03_1 = 0;
if SH_VAL03 = 2 then SH_VAL03_1 = 0;
if SH_VAL03 = 3 then SH_VAL03_1 = 1;
if SH_VAL03 = 4 then SH_VAL03_1 = 1;
label SH_VAL03_1 = "&students6 report that participating in school activities outside of class is Very important or Important to them";

if SH_VAL04 = 1 then SH_VAL04_1 = 0;
if SH_VAL04 = 2 then SH_VAL04_1 = 0;
if SH_VAL04 = 3 then SH_VAL04_1 = 1;
if SH_VAL04 = 4 then SH_VAL04_1 = 1;
label SH_VAL04_1 = "&students6 report that getting to class on time is Very important or Important to them";

if SH_VAL05 = 1 then SH_VAL05_1 = 0;
if SH_VAL05 = 2 then SH_VAL05_1 = 0;
if SH_VAL05 = 3 then SH_VAL05_1 = 1;
if SH_VAL05 = 4 then SH_VAL05_1 = 1;
label SH_VAL05_1 = "&students6 report that learning new things is Very important or Important to them";

if SH_VAL06 = 1 then SH_VAL06_1 = 0;
if SH_VAL06 = 2 then SH_VAL06_1 = 0;
if SH_VAL06 = 3 then SH_VAL06_1 = 1;
if SH_VAL06 = 4 then SH_VAL06_1 = 1;
label SH_VAL06_1 = "&students6 report that expressing their opinion in class is Very important or Important to them";

if SH_VAL07 = 1 then SH_VAL07_1 = 0;
if SH_VAL07 = 2 then SH_VAL07_1 = 0;
if SH_VAL07 = 3 then SH_VAL07_1 = 1;
if SH_VAL07 = 4 then SH_VAL07_1 = 1;
label SH_VAL07_1 = "&students6 report that getting invloved in the student council or other similar group is Very important or Important to them";

if SH_VAL08 = 1 then SH_VAL08_1 = 0;
if SH_VAL08 = 2 then SH_VAL08_1 = 0;
if SH_VAL08 = 3 then SH_VAL08_1 = 1;
if SH_VAL08 = 4 then SH_VAL08_1 = 1;
label SH_VAL08_1 = "&students6 report that learning about their culture/heritage is Very important or Important to them";

/*indicateur Q69 - SH_SLE01_1*/
if SH_SLE01 = 1 then SH_SLE01_1 = 0;
if SH_SLE01 = 2 then SH_SLE01_1 = 0;
if SH_SLE01 = 3 then SH_SLE01_1 = 0;
if SH_SLE01 = 4 then SH_SLE01_1 = 0;
if SH_SLE01 = 5 then SH_SLE01_1 = 0;
if SH_SLE01 = 6 then SH_SLE01_1 = 0;
if SH_SLE01 = 7 then SH_SLE01_1 = 0;
if SH_SLE01 = 8 then SH_SLE01_1 = 1;
if SH_SLE01 = 9 then SH_SLE01_1 = 1;
label SH_SLE01_1 = "&students6 report usually spending eight hours or more sleeping each night";

/*indicateur Q70 - SH_JOB01*/
if SH_JOB01 = . then SH_JOB01_1 = .;
else if (SH_JOBDH = 0) and (SH_JOBWE = 0) and (SH_JOBWD = 0) and (SH_JOBSV = 0) then SH_JOB01_1 = .;
else if (SH_JOB01 = 1) and (SH_JOBDH = 1) or
(SH_JOB01 = 2) and (SH_JOBDH = 0) or
(SH_JOB01 = 2) and (SH_JOBWE = 1) or
(SH_JOB01 = 2) and (SH_JOBWD = 1) or
(SH_JOB01 = 2) and (SH_JOBSV = 1) then SH_JOB01_1 = .;
else if SH_JOB01 = 1 then SH_JOB01_1 = 1;
else SH_JOB01_1 = 0;
label SH_JOB01_1 = "&students6 report having a part-time job outside of school";

/*indicateur Q71 - SH_JOBDH_1 SH_JOBWE_1 SH_JOBWD_1 SH_JOBSV_1*/
if SH_JOB01 = . then SH_JOBDH_1 = .;
else if (SH_JOBDH = 0) and (SH_JOBWE = 0) and (SH_JOBWD = 0) and (SH_JOBSV = 0) then SH_JOBDH_1 = .;
else if (SH_JOB01 = 1) and (SH_JOBDH = 1) or
(SH_JOB01 = 2) and (SH_JOBDH = 0) or
(SH_JOB01 = 2) and (SH_JOBWE = 1) or
(SH_JOB01 = 2) and (SH_JOBWD = 1) or
(SH_JOB01 = 2) and (SH_JOBSV = 1) then SH_JOBDH_1 = .;
else SH_JOBDH_1 = SH_JOBDH;
label SH_JOBDH_1 = "&students6 report not having a part-time job";

if SH_JOB01 = . then SH_JOBWE_1 = .;
else if (SH_JOBDH = 0) and (SH_JOBWE = 0) and (SH_JOBWD = 0) and (SH_JOBSV = 0) then SH_JOBWE_1 = .;
else if (SH_JOB01 = 1) and (SH_JOBDH = 1) or
(SH_JOB01 = 2) and (SH_JOBDH = 0) or
(SH_JOB01 = 2) and (SH_JOBWE = 1) or
(SH_JOB01 = 2) and (SH_JOBWD = 1) or
(SH_JOB01 = 2) and (SH_JOBSV = 1) then SH_JOBWE_1 = .;
else SH_JOBWE_1 = SH_JOBWE;
label SH_JOBWE_1 = "&students6 report usually working at their part-time job on the weekends";

if SH_JOB01 = . then SH_JOBWD_1 = .;
else if (SH_JOBDH = 0) and (SH_JOBWE = 0) and (SH_JOBWD = 0) and (SH_JOBSV = 0) then SH_JOBWD_1 = .;
else if (SH_JOB01 = 1) and (SH_JOBDH = 1) or
(SH_JOB01 = 2) and (SH_JOBDH = 0) or
(SH_JOB01 = 2) and (SH_JOBWE = 1) or
(SH_JOB01 = 2) and (SH_JOBWD = 1) or
(SH_JOB01 = 2) and (SH_JOBSV = 1) then SH_JOBWD_1 = .;
else SH_JOBWD_1 = SH_JOBWD;
label SH_JOBWD_1 = "&students6 report usually working at their part-time job on weekdays";

if SH_JOB01 = . then SH_JOBSV_1 = .;
else if (SH_JOBDH = 0) and (SH_JOBWE = 0) and (SH_JOBWD = 0) and (SH_JOBSV = 0) then SH_JOBSV_1 = .;
else if (SH_JOB01 = 1) and (SH_JOBDH = 1) or
(SH_JOB01 = 2) and (SH_JOBDH = 0) or
(SH_JOB01 = 2) and (SH_JOBWE = 1) or
(SH_JOB01 = 2) and (SH_JOBWD = 1) or
(SH_JOB01 = 2) and (SH_JOBSV = 1) then SH_JOBSV_1 = .;
else SH_JOBSV_1 = SH_JOBSV;
label SH_JOBSV_1 = "&students6 report usually working at their part-time job during school vacations";

/*supression des personnes sensibles pour certaines petites écoles*/
if SH_SCHID in (0513, 0609, 0752, 0802, 0839, 1215, 1224, 1401, 1503, 2104, 4113, 1213, 2522, 3326) then do;
SH_SEO02   = .;
SH_SEO01_1 = .;
SH_SEO01_2 = .;
SH_SEO01_3 = .;
SH_SEO01_4 = .;
SH_SEO01_5 = .;
SH_ALC01_1 = .;
SH_ALC03_1 = .;
SH_ALC03_2 = .;
SH_ALC04_1 = .;
SH_MAR01_1 = .;
SH_MAR02_1 = .;
SH_MAR02_2 = .;
SH_MAR02_3 = .;
SH_SAF01_1 = .;
SH_SAF02_1 = .;
SH_SEV01_1 = .;
SH_SEV01_2 = .;
SH_SEV01_3 = .;
SH_SEV02_1 = .;
SH_SEV02_2 = .;
SH_SEV02_3 = .;
SH_SEV03_1 = .;
SH_SEV03_2 = .;
SH_SEV03_3 = .;
end;

/*supression des variables inutiles*/
drop SCCMISS PROMISS RESMISS MEFTMISS OPPMISS MEFAMISS SOCMISS MEFCMISS MEFRMISS MEFFMISS MEFIMISS MEFSMISS SH_SCC001-SH_SCC005 SH_SCCTP SH_PRO001-SH_PRO005 SH_PROTP
SH_EATFV SH_EAT02a SH_EAT03a SH_EAT04a SH_EAT06a SH_RES001-SH_RES012 SH_RESTP SH_OPP001-SH_OPP007 SH_OPPTP TEMPa TEMPb SH_SOC001-SH_SOC005 SH_MEF001-SH_MEF018
SH_MEFTO SH_MEFAU SH_MEFCO SH_MEFRE SH_MEFFA SH_MEFFR SH_MEFSC SH_MEF03A SH_MEF06A SH_MEF09A SH_MEF12A SH_MEF15A SH_MEF18A SH_MEF01C SH_MEF04C SH_MEF07C SH_MEF10C
SH_MEF13C SH_MEF16C SH_MEF02R SH_MEF05R SH_MEF08R SH_MEF11R SH_MEF14R SH_MEF17R SH_MEF03F SH_MEF05F SH_MEF07F SH_MEF08F SH_MEF10F SH_MEF18F SH_MEF06I SH_MEF12I
SH_MEF13I SH_MEF14I SH_MEF16I SH_MEF17I SH_MEF01S SH_MEF02S SH_MEF04S SH_MEF09S SH_MEF11S SH_MEF15S;

/*creation de la macro qui inclut touts les indicateurs SWS1516 - ordre du questionnaire*/
%let SHINDQ = SH_GRADE_1 SH_GRADE_2 SH_GRADE_3  SH_GRADE_4 SH_GRADE_5 SH_GRADE_6 SH_GRADE_7 SH_AGE01_1 SH_AGE01_2 SH_AGE01_3 SH_AGE01_4 SH_AGE01_5 SH_AGE01_6 SH_AGE01_7
SH_AGE01_8 SH_AGE01_9 SH_AGE01_10 SH_GEN01_1 SH_GEN01_2 SH_GEN01_3 SH_LAN01_1 SH_LAN01_2 SH_LAN01_3 SH_LAN01_4 SH_LAN02_1 SH_LAN02_2 SH_LAN02_3 SH_LAN02_4
SH_ETHWH_1 SH_ETHBL_1 SH_ABO01_1  SH_ASI01_1 SH_LAT01_1 SH_IMM03_1 SH_HEP01_1 SH_LIF01_1 SH_LIF01_2 SH_LIF01_3 SH_LIF01_4 SH_LIF01_5 SH_LIF01_6 SH_BMI02_1
SH_BMI02_2 SH_BMI02_3 SH_BMI02_4  SH_BMI02_5 SH_SENAU_1 SH_SENBE_1 SH_SENBL_1 SH_SENDE_1 SH_SENAT_1 SH_SENIN_1 SH_SENLA_1 SH_SENLE_1 SH_SENPH_1 SH_SENME_1
SH_SENGI_1 SH_SENOT_1 SH_SENAL_1  SH_DAA01_1 SH_DAA02_1 SH_DAA02_2 SH_DAA02_3 SH_DAA02_4 SH_DAA02_5 SH_DAA03_1 SH_DAA03_2 SH_DAA03_3 SH_DAA03_4 SH_DAA03_5
SH_PHY01_1 SH_PHY02_1 SH_PHY02_2  SH_PHY02_3 SH_PHY03_1 SH_PHY03_2 SH_PHY03_3 SH_PHY03_4 SH_PHY03_5 SH_PHY03_6 SH_PHY04_1 SH_PHY04_2 SH_PHY04_3 SH_PHY05_1
SH_PHY05_2 SH_PHY05_3 SH_INSST_1  SH_INSIS_1 SH_INSVW_1 SH_INSAG_1 SH_INSSC_1 SH_INSSE_1 SH_INSCH_1 SH_INSOT_1 SH_INSAL_1 SH_OUSST_1 SH_OUSIS_1 SH_OUSVW_1
SH_OUSAG_1 SH_OUSCG_1 SH_OUSCH_1  SH_OUSOT_1 SH_OUSAL_1 SH_SCC01_1 SH_SCC02_1 SH_SCC03_1 SH_SCC04_1 SH_SCC05_1 SH_SCC06_1 SH_SCCTS_1 SH_PRO01_1 SH_PRO02_1
SH_PRO03_1 SH_PRO04_1 SH_PRO05_1  SH_PROTS_1 SH_EATFV_1 SH_EATNN_1 SH_DRI01_1 SH_DRI07_1 SH_DRINN_1 SH_EAT10_1 SH_EAT11_1 SH_EAT12_1 SH_EAT13_1 SH_EAT13_2
SH_EAT14_1 SH_EAT14_2 SH_SKBEA_1  SH_SKBDT_1 SH_SKBBE_1 SH_SKBSI_1 SH_SKBHM_1 SH_SKBFS_1 SH_SKBLW_1 SH_SKBNE_1 SH_SKBOT_1 SH_SCF01_1 SH_SCFBP_1 SH_SCFFV_1
SH_SCFHE_1 SH_SCFHF_1 SH_SCFHV_1  SH_SCFHC_1 SH_SCFIC_1 SH_SCFLP_1 SH_SCFSS_1 SH_FIN01_1 SH_MEFLO_1 SH_MEFMO_1 SH_MEFHI_1 SH_MEFHM_1 SH_MEFAU_1 SH_MEFCO_1
SH_MEFRE_1 SH_MEFFA_1 SH_MEFFR_1  SH_MEFSC_1 SH_MEF01_1 SH_MEF02_1 SH_MEF03_1 SH_MEF04_1 SH_MEF05_1 SH_MEF06_1 SH_MEF07_1 SH_MEF08_1 SH_MEF09_1 SH_MEF10_1
SH_MEF11_1 SH_MEF12_1 SH_MEF13_1  SH_MEF14_1 SH_MEF15_1 SH_MEF16_1 SH_MEF17_1 SH_MEF18_1 SH_RES01_1 SH_RES02_1 SH_RES03_1 SH_RES04_1 SH_RES05_1 SH_RES06_1
SH_RES07_1 SH_RES08_1 SH_RES09_1  SH_RES10_1 SH_RES11_1 SH_RES12_1 SH_RESTS_1 SH_RESTS_2 SH_DEP01_1 SH_BUVAO_1 SH_BUV01_1 SH_BUV02_1 SH_BUV03_1 SH_BUV04_1
SH_BUV05_1 SH_BUV06_1 SH_BUV07_1  SH_BUPAO_1 SH_BUP01_1 SH_BUP02_1 SH_BUP03_1 SH_BUP04_1 SH_BUP05_1 SH_BUP06_1 SH_BUP07_1 SH_BULII_1 SH_BULTP_1 SH_BULTT_1
SH_BULTR_1 SH_BULTA_1 SH_BULJB_1  SH_BUL01_1 SH_OPP01_1 SH_OPP02_1 SH_OPP03_1 SH_OPP04_1 SH_OPP05_1 SH_OPP06_1 SH_OPP07_1 SH_OPPTS_1 SH_ANX01_1 SH_LIN01_1
SH_LIN01_2 SH_LIN01_3 SH_SMO01_1  SH_SMO01_2 SH_SMO01_3 SH_SMO01_4 SH_SMO01_5 SH_SMO01_6 SH_SMO01_7 SH_SMO01_8 SH_SMO01_9 SH_SMOSU_1 SH_SMO05_1 SH_ALC01_1
SH_MAR01_1 SH_SMO06_1 SH_SMO06_2  SH_SMO06_3 SH_SMO06_4 SH_SMO07_1 SH_SMO07_2 SH_SMO08_1 SH_SMOLC_1 SH_SMOSC_1 SH_SMORC_1 SH_SMOSB_1 SH_SMOST_1 SH_SMONP_1
SH_SMOWP_1 SH_SMO09_1 SH_SMO09_2  SH_SMO10_1 SH_SMO11_1 SH_SMO12_1 SH_SMO13_1 SH_SMO14_1 SH_ALC03_1 SH_ALC03_2 SH_ALC04_1 SH_MAR02_1 SH_MAR02_2 SH_MAR02_3
SH_SAF01_1 SH_SAF02_1 SH_SAF03_1  SH_INJ01_1 SH_SEV01_1 SH_SEV01_2 SH_SEV01_3 SH_SEV02_1 SH_SEV02_2 SH_SEV02_3 SH_SEV03_1 SH_SEV03_2 SH_SEV03_3 SH_SEO01_1
SH_SEO01_2 SH_SEO01_3 SH_SEO01_4  SH_SEO01_5 SH_SMOBW_1 SH_SMOEC_1 SH_SMOAS_1 SH_VOL01_1 SH_VOL02_1 SH_VOL03_1 SH_VOL04_1 SH_VOL05_1 SH_VOLAT_1 SH_SOC01_1
SH_SOC02_1 SH_SOC03_1 SH_SOC04_1  SH_SOC05_1 SH_SOC06_1 SH_SOCTS_1 SH_VAL01_1 SH_VAL02_1 SH_VAL03_1 SH_VAL04_1 SH_VAL05_1 SH_VAL06_1 SH_VAL07_1 SH_VAL08_1
SH_SLE01_1 SH_JOB01_1 SH_JOBDH_1  SH_JOBWE_1 SH_JOBWD_1 SH_JOBSV_1;

/*creation de la macro qui inclut touts les indicateurs SWS1516 - ordre du rapport*/
/*%let SHINDR =*/
run;

/*vérification des indicateurs dans le BT*/
proc freq data = SWS1516n;
table &SHINDQ;
weight weightda;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Garnet | Level 18

## Re: Run the same data step on multiple data set without repeat all the data step

If I understand you correctly, you need use a macro program:

%let students6 = Students in grade 6 to 12 who;
%let students7 = Students in grade 7 to 12 who;

%macro doit(dsnin, dsnout);
data &dsnout;
set &dsnin;
.... your code ...
run;
%mend;
%doit(SWS1516m, SWS1516n);
%doit(FNAL1516 , FNAL1516a );
....
6 REPLIES 6
Super User

## Re: Run the same data step on multiple data set without repeat all the data step

If you are creating multiple output datasets in one data step you need use explicit OUTPUT statements to write the observations to the dataset(s) you want them written to.  An OUTPUT statement that does not list any datasets is the same as one that lists them all.  If you have no explicit OUTPUT statements then SAS will run an OUTPUT at the end of the step (just before the RUN statement).

Why are you combining the data if you don't want the data combined?

Calcite | Level 5

## Re: Run the same data step on multiple data set without repeat all the data step

Ok will try to figure how (where) to use to output statement in a datastep, never done this before.

I use SET because, for me it is the only way (sure not) to call dataset...

thanks

Garnet | Level 18

## Re: Run the same data step on multiple data set without repeat all the data step

If I understand you correctly, you need use a macro program:

%let students6 = Students in grade 6 to 12 who;
%let students7 = Students in grade 7 to 12 who;

%macro doit(dsnin, dsnout);
data &dsnout;
set &dsnin;
.... your code ...
run;
%mend;
%doit(SWS1516m, SWS1516n);
%doit(FNAL1516 , FNAL1516a );
....
Calcite | Level 5

## Re: Run the same data step on multiple data set without repeat all the data step

Work perfectly, Thanks alot. That will help me for many others things as well.
Super User

## Re: Run the same data step on multiple data set without repeat all the data step

Why do you have %LET statements between the DATA and RUN statements?  That will just confuse humans. The SAS compiler will run the macro code while compiling the datastep and thus before the step can start running.  So you should just move them to BEFORE the data step to make it clearer to humans reading the code the order of operation.

Super User

## Re: Run the same data step on multiple data set without repeat all the data step

One strongly suspects that most of those variables are not needed and that the approach used to do whatever is next is overly complicated as well.

One typical way with SAS to create separate output for levels of a variable is BY group processing, possibly coupled with Where clauses to restrict which data is used. Or other procedures.

Consider this code with a data set you should have available:

proc tabulate data=sashelp.class;
class sex age;
var height weight;
tables sex * (age all='Sex overall') all='All students',
(height weight)*(n mean max min std)
;
run;

This summarizes characteristics of height and weight for Sex and Age combinations, All within a single sex and All students in the data set.

Discussion stats
• 6 replies
• 558 views
• 1 like
• 4 in conversation