---
title: Cascading Style Sheets in ODS [CSSを利用したレポート作成]
tags:  #[第10回大阪sas勉強会]  
author: [森岡裕[SASユーザー総会世話人]](https://www.docswell.com/user/6484025)
site: [Docswell](https://www.docswell.com/)
thumbnail: https://bcdn.docswell.com/page/37KD849GED.jpg?width=480
description: [第10回大阪sas勉強会]
published: October 21, 24
canonical: https://www.docswell.com/s/6484025/59VWVM-2024-10-21-160527
---
# Page. 1

![Page Image](https://bcdn.docswell.com/page/37KD849GED.jpg)

The 10th
Osaka SAS
Study
Session
Cascading Style Sheets in ODS.
Satoshi Sekine
Fujimoto Pharmaceutical Corp.
CSSを利用したレポート作成
関根 暁史
（藤本製薬株式会社）


# Page. 2

![Page Image](https://bcdn.docswell.com/page/LJ3R2LW5E5.jpg)

The 10th
Osaka SAS
Study
Session
CSS（Cascading Style Sheets）
➢ Cascading Style Sheets (CSS) is a style sheet language used for specifying
the presentation and styling of a document written in a markup language such
as HTML or XML. CSS is a cornerstone technology of the World Wide Web,
alongside HTML and JavaScript. CSS is designed to enable the separation of
content and presentation,including layout, colors, and fonts.
「Wikipedia」
ods excel file=&quot;./CLASS.xlsx&quot; cssstyle=&quot;./STYLE.css&quot;;
Cssstyle
option
Using CSS
2


# Page. 3

![Page Image](https://bcdn.docswell.com/page/8JDYZNKYJG.jpg)

The 10th
Osaka SAS
Study
Session
Basics of the CSS
Selector{Property:Value;}
Cascading
The style defined
upstream is
inherited.
Where
What
How
3


# Page. 4

![Page Image](https://bcdn.docswell.com/page/VEP6D5K278.jpg)

The 10th
Osaka SAS
Study
Session
The report output of the default
ods excel file=&quot;./CLASS.xlsx&quot;
options(sheet_name=&quot;Student Data&quot;);
proc report data=sashelp.class;
run;
ods excel close;
MS PGothic
4


# Page. 5

![Page Image](https://bcdn.docswell.com/page/27V31PVXJQ.jpg)

The 10th
Osaka SAS
Study
Session
Making of the CSS
Header cells
th{font-family:Arial;background-color:#d3d3d3;font-size:10pt;fontweight:bold;border:1px solid #000000;}
td{font-family:Times New Roman;font-size:9pt;border:1px solid
#000000;}
Data part
This is saved as
“STYLE.css”.
5


# Page. 6

![Page Image](https://bcdn.docswell.com/page/5JG32PLREL.jpg)

The 10th
Osaka SAS
Study
Session
The report output that the CSS was imported
ods excel file=&quot;./CLASS.xlsx&quot;
cssstyle=&quot;./STYLE.css&quot;
options(sheet_name=&quot;Student Data&quot;);
proc report data=sashelp.class;
run;
ods excel close;
The appearance was
changed globally.
6


# Page. 7

![Page Image](https://bcdn.docswell.com/page/47Q5P2YYEP.jpg)

The 10th
Osaka SAS
Study
Session
Local cell（Color）
R1C2：Blue
tr:nth-child(1) td:nth-child(2){color:#0000ff;}
tr:nth-child(2) td:nth-child(2){color:#ff0000;}
R2C2:Red
7


# Page. 8

![Page Image](https://bcdn.docswell.com/page/KE49YLWZJ1.jpg)

The 10th
Osaka SAS
Study
Session
Local cell（BackgroundColor）
R6C3：Cyan
tr:nth-child(6) td:nth-child(3){backgroundcolor:#00ffff;}
tr:nth-child(8) td:nth-child(3){backgroundcolor:#ffc0cb;}
R8C3：Pink
8


# Page. 9

![Page Image](https://bcdn.docswell.com/page/L71K6LYDEG.jpg)

The 10th
Osaka SAS
Study
Session
The CSS that was made dynamically
filename _out &quot;./STYLE.css&quot; ;
data _null_; set sashelp.class;
obs=put(_n_,best.);
･･･
if sex=&quot;F&quot; then do;
wk=&quot;tr:nth-child(&quot;||strip(obs)||&quot;) td:nth-child(2){color:#ff0000;}&quot;;*red;
put wk;
end;
if sex=&quot;M&quot; then do;
wk=&quot;tr:nth-child(&quot;||strip(obs)||&quot;) td:nth-child(2){color:#0000ff;}&quot;;*blue;
put wk;
end;
if .&lt;age&lt;=12 then do;
wk=&quot;tr:nth-child(&quot;||strip(obs)||&quot;) td:nth-child(3){backgroundcolor:#00ffff;}&quot;;*cyan;
put wk;
end;
if age&gt;=15 then do;
wk=&quot;tr:nth-child(&quot;||strip(obs)||&quot;) td:nth-child(3){backgroundcolor:rgb(234,145,152);}&quot;;*pink;
put wk;
end;
run;
9


# Page. 10

![Page Image](https://bcdn.docswell.com/page/G7WDWVG8E2.jpg)

The 10th
Osaka SAS
Study
Session
The CSS that was made dynamically
Male：Blue
12years or
younger：Cyan
Female：
Red
15years or
older：Pink
It is good for expression out of a clinical
inspection standard value range！
10


# Page. 11

![Page Image](https://bcdn.docswell.com/page/4JZG54L973.jpg)

The 10th
Osaka SAS
Study
Session
The appearance similar to CDISC
similar to CDISC
th{background-color:#6699CC;color:#ffffff;}
tr:nth-child(odd) td{background-color:#ffffff;}
Odd number line(2n+1)
tr:nth-child(even) td{background-color:#e2e2e2;}
Even number line(2n)
11


# Page. 12

![Page Image](https://bcdn.docswell.com/page/YE6Y93WDJV.jpg)

The 10th
Osaka SAS
Study
Session
The appearance similar to CDISC
The style imitates CDISC.
Converted into RTF
12


# Page. 13

![Page Image](https://bcdn.docswell.com/page/GE5GNLM8E4.jpg)

The 10th
Osaka SAS
Study
Session
The appearance was changed for each seat
ID for the Class sheet
#class th{background-color:orange;}
#bmt th{background-color:#6699CC;color:white;}
ods excel options(sheet_name=&quot;Class&quot;) anchor=&quot;class&quot;;
proc report data=sashelp.class;
run;
ods excel options(sheet_name=&quot;BMT&quot;) anchor=&quot;bmt&quot;;
proc report data=sashelp.bmt;
run;
ID for the BMT sheet
#class
#bmt
13


# Page. 14

![Page Image](https://bcdn.docswell.com/page/972Y5L9V7R.jpg)

The 10th
Osaka SAS
Study
Session
The appearance was changed for each seat
The header part was
painted in orange.
The header part was
painted in skyblue.
14


# Page. 15

![Page Image](https://bcdn.docswell.com/page/DJYGKQ4QJM.jpg)

The 10th
Osaka SAS
Study
Session
Conclusion
➢ The CSS makes the appearance change of the document globally without
“proc template” technology.
➢ The CSS makes the appearance change of the document locally without
“compute” or “call define” technology.
➢ The CSS is imported in both “ODS Excel” and “ODS RTF”.
About a change of the
appearance, CSS substitutes
proc template and proc report.
15


# Page. 16

![Page Image](https://bcdn.docswell.com/page/V7NGRKY2E8.jpg)

The 10th
Osaka SAS
Study
Session
References
➢ Cynthia L. Zender (2009)．CSSSTYLE: Stylish Output with ODS and SAS，
SAS Global Forum 2009, Paper 014-2009
➢ Kevin D. Smith (2011)．Unveiling the Power of Cascading Style Sheets (CSS)
in ODS，SAS Institute Inc., Paper 297-2011
➢ SAS Institute Inc. (2011)．SAS9 ODS Cascading Style Sheet (CSS) Tip Sheet
➢ William E Benjamin Jr (2018)．Working with the SAS ODS EXCEL Destination
to Send Graphs, and Use Cascading Style Sheets When Writing to EXCEL，
PharmaSUG 2018, Paper HT-05
16


# Page. 17

![Page Image](https://bcdn.docswell.com/page/YJ9WMVPDJ3.jpg)

The 10th
Osaka SAS
Study
Session
Thank you for your attention.
17


