* Example 1: 열에 대한 출력 양식 정의하기;
options nodate obs=15;
title "Customizing Columns";
proc odstable data=sashelp.class;
column age sex height weight;
define age;
style={fontsize=10pt just=l borderrightstyle=dashed background=yellow};
header='Age of Student';
format=3.;
end;
define sex;
style={fontsize=10pt just=l borderrightstyle=dashed};
header='Gender';
end;
define height;
style={fontsize=10pt just=l foreground=blue borderrightstyle=dashed};
header='Height';
end;
run;
* Example 2: COLUMN 구분을 사용하여 변수 정의하기;
title "Dealer Profit Assuming Three Percent Holdback";
proc odstable data=sashelp.cars(obs=15);
column Make Model Msrp Holdback;
define holdback;
compute as (msrp * .03) ;
label="3% Dealer Holdback";
format=dollar10.2;
end;
define msrp;
print=off;
end;
run;
* Example 3: 사용자 정의 테이블 템플릿 생성 및 저장;
* 확인방법 : 결과 창 결과 메뉴에서 오른쪽 마우스 -> 템플릿 선택 -> 템플릿 창 Open;
options nodate obs=15;
title;
proc odstable data=sashelp.class name=odstableExample store=Sasuser.MyExampleTemplates;
column age sex height weight;
define age;
style={fontsize=10pt just=l borderrightstyle=dashed background=yellow};
header='Age of Student';
format=3.;
end;
define sex;
style={fontsize=10pt just=l borderrightstyle=dashed};
header='Gender';
end;
define height;
style={fontsize=10pt just=l foreground=blue borderrightstyle=dashed};
header='Height';
end;
run;
proc template;
delete odstableExample / store=Sasuser.MyExampleTemplates;
run;
* Example 4: PROC TEMPLATE 과 PROC ODSTABLE 사용하기;
ods path reset;
ods path show;
ods html close;
options nodate;
ods html;
* ods pdf file="ProcOdstableTable.pdf";
title "Using PROC ODSTABLE";
proc odstable name=Base.Template.Table;
define header myheader1;
text "Use the CELLSTYLE-AS Statement to Customize Output";
style={color=red};
end;
define header myheader2;
text "Use PROC ODSTABLE to Create a Table Template";
style={color=red};
end;
define footer myfooter;
text "This output is formated with a master template.";
style={color=blue};
end;
cellstyle _row_ in (13) as {BackgroundColor=Palegreen },
_row_ in (12) as {BorderBottomStyle=Solid },
_row_ in (11) as {BackgroundColor=Limegreen },
mod(_row_,2) as {Background=Honeydew},
_col_ = 1 as {Width=1.2in BorderLeftColor=Black},
_col_ = 2 as {Width=2in},
_col_ = 3 as {Width=.6in},
_col_ = 4 as {Width=.5in},
_col_ = 5 as {Width=.9in};
run;
proc sql;
select * from sashelp.class;
run;
quit;
proc odstable name=Base.Template.Table store=mystore;
cellstyle _row_ in (16) as {BackgroundColor=Palegreen },
_row_ in (15) as {BorderBottomStyle=Solid },
_row_ in (14) as {BackgroundColor=Limegreen },
mod(_row_,2) as {Background=Honeydew},
_col_ = 1 as {Width=1.2in BorderLeftColor=Black},
_col_ = 2 as {Width=2in},
_col_ = 3 as {Width=.6in},
_col_ = 4 as {Width=.5in},
_col_ = 5 as {Width=.9in};
run;
ods path (prepend) Mystore;
ods path show;
proc sql;
select * from sashelp.class;
run;
quit;
ods html close;
* ods pdf close;
ods html;
proc template;
delete base.template.table;
delete base.template.table / store=mystore;
run;
ods path reset;
* Example1 : Using PROC DOCUMENT to Work with Table Templates;
* ODS 문서 생성;
ods document name=SqlTempl(write);
proc sql;
title "Cars with City MPG Greater Than 25";
select Make, Model, MPG_City, MPG_Highway
from sashelp.cars
where MPG_City >25;
run;
quit;
proc sql;
title "Cars with City MPG Greater Than 40";
select Make, Model, MPG_City, MPG_Highway
from sashelp.cars
where MPG_Highway >40;
run;
quit;
ods document close;
title;
* 출력 개체를 출력( WORK 폴더 : sqltempl.sas7bitm 파일 );
proc document name=SqlTempl;
list / levels=all;
run;
quit;
* 두 테이블과 연관된 테이블 템플릿 확인;
proc document name=SqlTempl;
obtempl \SQL#1\SQL_Results#1;
obtempl \SQL#2\SQL_Results#1;
run;
quit;
* 새 항목 저장소에 사용자 지정 테이블 서식 파일을 생성.;
proc odstable name=Base.SQL store=mystore;
cellstyle _DATANAME_ = "MPG_City" and _val_ gt (40) as {background=green},
mod(_row_,2) as {Background=Honeydew};
run;
proc odstable name=Base.SQL;
cellstyle _DATANAME_ = "MPG_Highway" and _val_ gt (50) as {background=red},
mod(_row_,2) as {Background=yellow};
run;
proc document name=sqlTempl;
replay \SQL#2\SQL_Results#1,
\SQL#1\SQL_Results#1(store=mystore);
run;
quit;
proc template;
delete Base.SQL;
delete Base.SQL / store=mystore;
run;
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.