1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
data test;
input ID1 info1 $ ID2 ;
cards;
1 A 1
2 B 1
3 C 2
4 B 2
5 A 2
6 B 3
7 F 4
8 B 4
9 D 5
10 Z 5
;
run;
proc sql;
create table test2
as select ID1
,info1
, ID2
, case
when min(info1 eq "B") then "x" /* il n'y a que B */
else
case
when max(info1 eq "B") /* présence de B */
and max(info1 eq "A") /* présence de A */
and max(info1 not in ("A", "B")) /* présence autre */
then "z"
else
case
when max(info1 eq "B") /* présence de B */
and max(info1 eq "A") /* présence de A */
and (max(info1 not in ("A", "B")) eq 0) /* absence d'autre */
then "y" /* seulement A et B */
end
end
end as col
from test
group by ID2;
quit; |
Partager