BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ddotta
Calcite | Level 5
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 !

1 ACCEPTED SOLUTION

Accepted Solutions
sam369
Obsidian | Level 7


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;

View solution in original post

5 REPLIES 5
ballardw
Super User

Please state the condition rules.

 

I can make that output but it probably would not work for any other records.

ddotta
Calcite | Level 5

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

ddotta
Calcite | Level 5
not the same question
sam369
Obsidian | Level 7


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;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 708 views
  • 0 likes
  • 4 in conversation