BookmarkSubscribeRSS Feed

[SAS 활용 노하우] PROC PLOT/CHART

Started ‎09-17-2023 by
Modified ‎09-17-2023 by
Views 106

PROC PLOT과 PROC CHART statement 는 텍스트 형태를 그림을 활용하여 도표를 그릴 수 있다.

■ PROC PLOT

PROC PLOT은 두 변수 사이의 관계를 그림의 형식으로 표현한다.

 

 

proc plot data = sasuser.htwt;
plot height*age = 'j' weight*age = gender/hpos=30 vpos=15 overlay;
run;

 

 

 

위의 예제는 PROC PLOT statement의 간단한 예시입니다.

먼저, PLOT statement로 수직축 변수 height , weight 로 설정을 했으며, 수평축 변수로 age를 설정했다.

위의 예시에서 보면, PLOT height(가로축)*age(세로축)의 관계를 그림으로 표현했을 때 표현형식을 텍스트인 'j'로 설정했다.

그리고 weight*age PLOT의 경우에는 gender로 설정했다.

 

 

 

image.png

 

 

 

위와 같이 플롯에 표현할 문자나 변수를 지정해서 설정할 수 있다.

OVERLAY 옵션은 동일한 PLOT 문 안에 있는 모든 플롯을 하나의 그림에 겹쳐서 그려주는 옵션이다.

플롯을 개별적으로 그리고 싶다면 OVERLAY 를 지우면된다.

HPOS 옵션과 VPOS 옵션은 수평축 길이와 수직축 길이를 설정하는 것이다.

■ PROC CHART

 

 

 

PROC CHART DATA = data-set options;
BLOCK variables / options;
BY variables;
HBAR variables / options;
PIE variables;
STAR variables;
VBAR variables;
RUN;

 

 

 

 

CHART statement 는 수평막대도표, 수직막대도표, 파이도표, 별도표 등 명령문을 이용하여 다양한 도표를 그릴 수 있다.

  • HBAR: 수평막대그래프으로 범주형 변수의 빈도를 표시하는데 사용된다.

  • VBAR: 수직막대그래프로 범주형 변수의 빈도를 시각화하는데 사용된다.

  • PIE: 원 그래프를 생성하여 범주형 변수의 상대적 비율을 알 수 있다.

  • BUBBLE: 버블 차트를 이용하여 세가지 변수의 관계를 시각화한다.

  • STAR: 스타플롯을 생성하여 다변량 데이터의 패턴을 시각화한다.

아래의 예시는 cars 데이터의 차 브랜드 변수인 make를 PIE 옵션으로 PLOT을 그려보았다.

 

 

proc chart data = sashelp.cars;
pie make;
run;

 

 

 image (1).png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Version history
Last update:
‎09-17-2023 08:03 AM
Updated by:
Contributors

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

Article Labels
Article Tags