data temp;
input siren $ class $ imput $;
cards;
A CP titi
B CP toto
C CE tata
D CE tata
F CM toto
G CM toto
H SU tata
I SU toto
;
run;
The output I want :
siren class imput
A CP titi
C CE tata
D CE tata
F CM toto
G CM toto
H SU tata
Many thanks in advance !
proc sql;
create table want as
select a.*
from temp as a left join (select *,count(imput) as cnt from temp where imput='toto' group by class ) as b on (a.class=b.class & a.siren=b.siren)
having missing(b.cnt) or b.cnt>=2
order by a.siren,a.class;
quit;
Please state the condition rules.
I can make that output but it probably would not work for any other records.
I would like delete some observations in some groups based on a condition. My condition is each group : if (imput="toto") then delete but if a whole group has imput="toto" then keep it
proc sql;
create table want as
select a.*
from temp as a left join (select *,count(imput) as cnt from temp where imput='toto' group by class ) as b on (a.class=b.class & a.siren=b.siren)
having missing(b.cnt) or b.cnt>=2
order by a.siren,a.class;
quit;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.