[ Retour aux Travaux Dirigés de SAS ]
/* Statistiques avec SAS, Préparation pour q0cal (TD3) */
/* Jean-Sebastien Roy (js@jeannot.org), 2000 */
%let chemin=//diamant/Data Mi2/sas/stats;
libname tables "&chemin/tables";
filename donnees "&chemin/infiles";
data cal0;
length cday $ 1;
infile donnees('Angleterre');
input aa 11-12 mm 13-14 dd 15-16 demi 17 cday $ 20;
if demi=1;
if aa<60 then aa=aa+2000;
else aa=aa+1900;
mdy(mm,dd,aa);
format date ddmmyy10.;
keep date cday;
run;
/* Creation d'une variable type de jour (TDAY) dans le calendrier */
data cal;
set cal0;
length tday $ 1 wday 3 ;
wday=weekday(date); /* Le jour de la semaine : 1=Dimanche */
if wday=1 then tday='D'; /* dimanche */
else if wday=2 then tday='L'; /* lundi */
else if wday=6 then tday='V'; /* vendredi */
else if wday=7 then tday='S'; /* samedi */
else tday='O'; /* autres */
if cday='4' then tday='D'; /* Jour férié -> Dimanche */
else if cday='5' then do; /* Lend. de JF */
if tday='O' then tday='L'; /* Autres -> Lundi */
else if tday='S' then tday='D'; /* Samedi -> Dimanche */
end;
else if cday='7' and tday='O' then tday='V'; /* Veille de JF -> Vendredi */
keep date wday cday tday;
run;
/* Lien Q0 <-> Calendrier */
data q0cal0;
set tables.q0;
datepart(dtu);
run;
data tables.q0cal;
merge q0cal0 ( inq0)
cal ( incal);
by date;
if inq0 and incal; /* Informations présentes dans les deux tables seulement*/
run;