끄적이는 프로그래밍/SAS 프로그래밍

SAS로 RTF 파일 출력하기 1

요맘때10 2022. 5. 4. 17:02
반응형

기본 형태

ods listing close;
options nodate nonumber orientation=portrait; 

ods rtf file="출력파일경로\출력파일명.RTF";

procedure or ods text
...

ods rtf close;
ods listing;

기본 형태의 틀에 하나씩 추가하면 된다.

만약 가로형태로 출력하고 싶다면 orientation=landscape 를 적용한다.

1. Header, Footer의 적용

ods listing close;
options nodate nonumber orientation=portrait; 

ods rtf file="출력파일경로\출력파일명.RTF";

Title1      "제목 1";
Title2      "제목 2";
...
Footnote1 "주석 1";
Footnote2 "주석 2";
...

procedure or ods text
...

ods rtf close;
ods listing;

2. 문서의 스타일 적용 - Proc template이 있는 경우 사용

ods listing close;
options nodate nonumber orientation=portrait style=스타일명

ods rtf file="출력파일경로\출력파일명.RTF";

Title1      "제목 1";
Title2      "제목 2";
...

Footnote1 "주석 1";
Footnote2 "주석 2";
...

procedure or ods text
...

ods rtf close;
ods listing;
반응형


3. ODS Escapechar

ods rtf, excel 등 ods 문장 내에서 스타일을 적용할 때 이용하면 편리하다.

자주 사용하지 않는 문자를 지정하는 것이 좋다(~, ^ 등).

 

3-1. ^S={}을 이용한 스타일 지정

ods listing close;
options nodate nonumber orientation=portrait style=스타일명; 

ods rtf file="출력파일경로\출력파일명.RTF";

ods escapechar = "^";

Title1      "제목 1";
Title2      "제목 2";
...
Footnote1 "주석 1";
Footnote2 "주석 2";
...

ods rtf text="^S={color=black font_size=10pt font_weight=bold}{Hello world 1}";
ods rtf text="^S={color=green font_size=12pt font_weight=medium}{Hello world 2}";
ods rtf text="^S={color=red font_size=14pt font_weight=medium}{Hello world 3}";

...

ods rtf close;
ods listing;

3-2. ^R'\' 을 이용한 스타일 지정

ods listing close;
options nodate nonumber orientation=portrait style=스타일명; 

ods rtf file="출력파일경로\출력파일명.RTF";

ods escapechar = "^";

Title1      "제목 1";
Title2      "제목 2";
...
Footnote1 "주석 1";
Footnote2 "주석 2";
...

ods rtf text="^S={color=black}^R'\b\fs20' Hello world 1";
ods rtf text="^S={color=green}^R'\fs24' Hello world 2";
ods rtf text="^S={color=red}^R'\fs28' Hello world 3";

...

ods rtf close;
ods listing;

 

2편에 계속...

반응형