/* EXERCICE 1 */ /* question 1 */ data Mercury; infile "Mercury.txt" expandtabs ; input id lake$ alkalinity ph calcium cholophyll avg_m nosamples minn maxx yrstd age_data ; run; /* question 2 */ proc print data=mercury; run; /* 53 obs */ /* question 3 */ data mercury_age; set mercury; if age_data=1; drop age_data; /* 43 obs et 11 var */ data no_age; set mercury; if age_data=0; drop age_data; /* 10 obs et 11 var */ proc print data=mercury_age; run; proc print data=no_age; run; /* question 4 */ proc means data=mercury_age; var alkalinity ph calcium cholophyll avg_m nosamples minn maxx yrstd; run; /* pas de données manquantes */ proc corr data=mercury_age; var alkalinity ph avg_m yrstd; run; /* toutes les variables sont corrélées entre elles */ /* question 5 */ proc univariate data=mercury_age normal; var alkalinity yrstd; histogram alkalinity yrstd/normal; run; /* question 6 */ data n_mercury_age; set mercury_age; log_alkalinity=log(alkalinity); log_yrstd=log(yrstd); run; /* question 7 */ proc univariate data=n_mercury_age normal; var log_alkalinity log_yrstd; /* toutes les deux sont de loi Normale */ histogram log_alkalinity log_yrstd/normal; run; /* question 8 */ proc means data=n_mercury_age; var log_alkalinity log_yrstd; run; /* 2.99 et -0.82 */ /* question 9 */ data n2_mercury_age; set n_mercury_age; diff=log_alkalinity-log_yrstd; proc univariate data=n2_mercury_age; var diff; run; /* ou */ proc ttest data=n2_mercury_age ; var diff; run; /* pas la meme moyenne */ /* question 10 */ data n3_mercury_age; set mercury_age; if calcium<25 then conc="faible"; if calcium>=25 & calcium<75 then conc="moyen"; if calcium>75 then conc="eleve"; proc print; run; /* question 11 */ Proc freq data=n3_mercury_age; table conc /chisq; run; /* les trois proportions ne sont pas égales */ /* Exercice 2 */ proc sort data=mercury ; by pH; run; axis1 value=(c=green) label=(c=green "alkalinity"); axis2 value=(c=black) label=(c=black "pH"); proc gplot data=mercury; plot alkalinity*pH / vaxis=axis1 haxis=axis2; symbol1 interpol=j color=blue v=star; title "alkalinity fonction du pH"; run; quit; /* Exercice 3 ***/ /* question 1 */ option mprint mlogic symbolgen; %macro calcul(tab,var,seuil); data nouv ; set &tab ; if &var<&seuil; data _Null_; set nouv nobs=n; call symput ("nligne",n); run; %put "le nombre d observations du tableau &tab avec la variable &var inferieure à &seuil est egale à &nligne"; run; %mend; %calcul(mercury,ph,5) ; /* 7 observations */ %calcul(mercury,calcium,25) ; /* 37 observations */