BookmarkSubscribeRSS Feed

[SAS 활용 노하우] 데이터 가공 3

Started ‎12-19-2023 by
Modified ‎12-19-2023 by
Views 542

 

 

■ Drop

출력될 데이터 셋에서 변수를 제거하여 출력할 수 있습니다.

data bacteria;
set sasuser.bacteria(drop= temp div);
run;
 
image (6).png

 

 
sasuser의 bacteria 데이터는 중 temp, div 변수를 제거하였습니다.
 
 
data bacteria(drop= temp div);
set sasuser.bacteria;
run;
 
 

data문 또는 set문에서 DROP statement를 쓰면 같은 결과가 출력됩니다.

■ WHERE

SQL문의 where구문과 동일하게 조건에 맞는 데이터를 출력할 수 있습니다.

and / or 등을 이용해 조건을 세부화할 수 있습니다.

 

data bacteria;
set sasuser.bacteria;
where temp >= 10 and div < 10;
run;

 

bacteria 데이터 중 temp 가 10이상, div 가 10 이하의 데이터를 출력했습니다.

 
 
image (7).png

 

 

그 결과, 100개의 데이터 중 29개의 데이터가 조건에 맞게 출력됐습니다.

■ Like

WHERE statement 와 Like 문이 같이 사용되며 조건문 안에서 특정 값을 포함하는 데이터를 출력할 수 있습니다.

 

 

data odsstyle;
set stpsamp.odsstyle;
where style like'%.Excel';
run;

 

image (8).png

 

 

STPSAMP라이브러리에 ODSSTYLE은 총 115개의 데이터가 있다. style 변수 중 '.Excel' 로 끝나는 데이터를 출력한 결과, 2개가 출력되었다.

 

 

Version history
Last update:
‎12-19-2023 08:58 AM
Updated by:
Contributors

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Article Labels
Article Tags