BookmarkSubscribeRSS Feed
PARKSA
Calcite | Level 5

PARKSA_0-1672216923097.png

오직 a만 있는 id들만 남겨두고 싶을 때(b or c or d를 갖는 id들은 모두 삭제) 사용가능한 코드가 있을까요?

sas초보라 아직 너무 어렵습니다 ㅠㅠ 도와주세요

 

2 REPLIES 2
Chulgyu1
SAS Employee

그냥 쉽게 한번 작성해 봤습니다.

추가로 하시고자 하는 부분이 있으시면 이 코드를 기반으로 조금씩 수정하셔서 사용하시면 될 듯 합니다.

data tmp01;
  input id $ item $;
  datalines;
1 a
1 b
1 c
1 d
2 a
2 a
2 a
2 a
run;
proc sort data=tmp01 out=tmpa nodupkey;
  by id;
  where item='a';
run;
proc sort data=tmp01 out=tmpbcd nodupkey;
  by id;
  where item in ('b','c','d');
run;

data final;
  merge tmpa(in=in1) tmpbcd(in=in2);
  by id;
  if not in2;
run;

proc print data=work.final;
run;
joinos
Calcite | Level 5
data tmp01;
DATA a1; 
input id $ item $; datalines; 1 a 1 b 1 c 1 d 2 a 2 a 2 a 2 a run;
DATA b1; SET a1;
IF item='a';
RUN;
어렇게 간단하게 하면 될 것 같은데요?

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!

Discussion stats
  • 2 replies
  • 513 views
  • 1 like
  • 3 in conversation