SQL avec condition multiples sur une autre database
Bonjour,
j'ai un soucis avec mon code SQL qui me renvoie quelque chose d'absurde.
je vous explique en deux mots :
J'ai deux versions de la même base de données. Une datant de Nov 2011, une de 2013. Je souhaite savoir l'état du nombre de dose en Nov 2011 parmi ceux qui ont reçus un vaccin après le 1er Nov 2011. Le tout parmi mes participant (non exclus).
Après pas mal de recherche je suis arrivée là :
Code:
1 2 3 4 5 6 7 8 9
| proc SQL;
create view rapport as
select date_vac1, date_vac2, date_vac3, NbDose, DoseValide, StatutProt, ExclusTot
from rougeole.Nov2011
where ExclusTot = 0 AND (date_vac1 IN (select date_vac1 FROM rougeole.obj2013 where date_vac1 >= MDY(11,01,2011)) OR date_vac2 IN (select date_vac2 FROM rougeole.obj2013 where date_vac2 >= MDY(11,01,2011))OR date_vac3 IN (select date_vac3 FROM rougeole.obj2013 where date_vac3 >= MDY(11,01,2011)));
quit;
proc freq data=rapport;
tables NbDose DoseValide StatutProt / nocol norow nopercent;
run; |
Ce qui semblait fonctionner vu qu'il me dit en sortie:
Citation:
NOTE: SQL view WORK.RAPPORT a été définie
Après je fais mon proc freq sur la base rapport :
Code:
1 2 3
| proc freq data=rapport;
tables NbDose DoseValide StatutProt / nocol norow nopercent;
run; |
Et il me retourne :
Citation:
NOTE: There were 997086 observations read from the data set ROUGEOLE.NOV2011.
WHERE ExclusTot=0;
NOTE: There were 36638 observations read from the data set ROUGEOLE.OBJ2013.
WHERE date_vac1>='01NOV2011'D;
NOTE: There were 57483 observations read from the data set ROUGEOLE.OBJ2013.
WHERE date_vac2>='01NOV2011'D;
NOTE: There were 16741 observations read from the data set ROUGEOLE.OBJ2013.
WHERE date_vac3>='01NOV2011'D;
NOTE: There were 55 observations read from the data set WORK.RAPPORT
Que je ne comprend pas. J'ai beaucoup plus d'observations que ça dans ce que je cherche.