/* EXERCICE 1 */ /* question 1 */ data pharynx; infile "C:....\M2PRO\an2013\logicielSAS\pharynx.dat"; input case inst$ sex$ tx$ grade$ age cond $ site$ t_stage$ n_stage$ entry_dt status$ time; run; /* question 2 */ proc print data=pharynx; run; /* 195 observation */ /* question 3 */ proc freq data=pharynx; tables inst sex tx grade cond site t_stage n_stage status /chisq; run; /* question 4 */ proc freq data=pharynx; tables t_stage*n_stage / chisq; run; /* les variables sont corrélées */ /* question 5 */ proc means data=pharynx; var age time; run; /* question 6 */ proc corr data=pharynx; var age time; run; /* question 7 */ proc univariate data=pharynx normal plot; var age ; run; /* question 8 */ proc univariate data=pharynx; histogram age /normal; qqplot age / normal; run ; /**** OU ****/ proc gchart data=pharynx ; vbar age ;run; quit; data phar; set pharynx ; nn=1; proc boxplot data=phar; plot age*nn; run; /* question 9 */ proc plot data=pharynx; plot time*age="*" $sex; run; /* question 10 */ data q10; set pharynx; if (tx=1 & status=0) then nv="A"; if (tx=1 & status=1) then nv="B"; if (tx=2 & status=0) then nv="C"; if (tx=2 & status=1) then nv="D"; run; proc print data=q10; run; /* question 11 */ data numeriques; set q10; keep age time; file "C:\Users\gabriela\M2PRO\an2013\logicielSAS\numeriques.txt"; put age time; run; data caracteres; set q10; keep inst sex tx grade cond site t_stage n_stage status nv; file "C:\Users\gabriela\M2PRO\an2013\logicielSAS\caracteres.txt"; put inst sex tx grade cond site t_stage n_stage status nv; run; run; /* EXERCICE 2 ***/ proc iml; /* question 1 */ use pharynx; read all var {age time} into X; close pharynx; print(X); /* question 2 */ print("l age de l obs 93 est "); print(X[93,1]); X[93,1]=57; print("la nouvelle valeur de l age pour obs 93 est "); print(X[93,1]); /* question 3*/ v=j(nrow(x),1,1); do i=1 to nrow(v); if x[i,1]<=25 then v[i]=1; if (x[i,1]>25 & x[i,1]<50) then v[i]=2; if (x[i,1]>=50 & x[i,1]<=75) then v[i]=3; if x[i,1]>25 then v[i]=4; end; /* question 4 */ Y=x[,1] || V; print(Y); /* question 5 */ create Y from Y ; append from Y; close Y; quit; /** EXERCICE 4 ****/ /* question 1 */ data t1; set q10; drop age; data final; merge t1 Y; age=col1; tr=col2; drop col1 col2; proc print data=final; run; /* question 2 */ data correct; set final; if case=125 then delete; proc print data=correct; run; /*** Exercice 4 **/ proc sort data=correct ; by time; run; axis1 value=(c=red) label=(c=red "age"); axis2 value=(c=blue) label=(c=blue "time"); proc gplot data=correct; plot age*time / vaxis=axis1 haxis=axis2; symbol1 interpol=j color=blue v=star; title "age fonction du temps de guérison"; run; quit; /* Exercice 5 ***/ /* question 1 */ option mprint mlogic symbolgen; %let m_tab=correct; %let m_time=time; %let m_age=age; %let m_status=status; %let m_stage=t_stage; /*** question 2 **/ %macro corr1(V1,V2,t); proc corr data=&m_tab; var &V1 &V2; run; %mend corr1; %corr1(&m_age,&m_time,&m_tab) /* question 3 */ %macro corr2(V1,V2,t); proc freq data=&m_tab; tables &V1 &V2; run; %mend corr1; %corr2(&m_status,&m_stage,&m_tab) /****************** FIN *******************/