Previous Page | Next Page

TEMPLATE Procedure: Creating a Style Template (Definition)

Example 6: Importing a CSS file


PROC TEMPLATE features:

DEFINE STYLE statement:

CLASS statement

IMPORT statement:

media-type

PARENT= statement

Other ODS features:

ODS HTML statement

ODS PDF statement

ODS _ALL_ CLOSE statement



Program Description

The following program imports the external CSS file StyleSheet.css and converts the CSS code into style elements and style attributes. These style elements and attributes then become part of the style.

Your CSS file can contain media blocks that correspond to the type of media that your output will be rendered on. The IMPORT statement allows you to specify one or more media blocks to be imported along with the rest of the CSS code. In this example, the Print media block is included in the style that is applied to the PDF output.


Program

 Note about code
.body {
   background-color: white;
    color: black;
    font-family: times, serif;
}
.header, .rowheader, .footer, .rowfooter, .data {
    border: 1px black solid;
    color: black;
    padding: 5px;
    font-family: times, serif;
}
.header, .rowheader, .footer, .rowfooter {
    background-color: #a0a0a0;
}
.table {
    background-color: #dddddd;
    border-spacing: 0;
    border: 1px black solid;
}
.proctitle {
    font-family: helvetica, sans-serif;
    font-size: x-large;
    font-weight: normal;
}

@media screen {
 
   .header, .rowheader, .footer, .rowfooter,{
      color: white;
      background-color: green;}
   .table {
      background-color: yellow;
      border-spacing: 0;
      font-size: small
      border: 1px black solid;

}
}@media print {

  .header, .rowheader, .footer, .rowfooter,{
      color: white;
      background-color: Blue;
      padding: 5px;
}
  .data {
      font-size: small;
}
}
options nodate pageno=1 linesize=80 pagesize=40 obs=10;

 Note about code
proc template;
define style styles.mycssstyle;
    import "StyleSheet.css";
    class data / 
        color = red;
end;
 Note about code
define style styles.mycssstyleprinter; 
        parent=styles.mycssstyle;
        import "StyleSheet.css" print;
end;
run;
 Note about code
ods html file="css.html" style=styles.mycssstyle;
ods pdf file="css.pdf" style=styles.mycssstyleprinter;

proc contents data=sashelp.class; 
run;
 Note about code
ods _all_ close;

Output

MyCssStyle Style

proc template;                                                                
   define style Styles.Mycssstyle / store = SASUSER.TEMPLAT;                  
      class body /                                                            
         fontfamily = "times, serif"                                          
         color = #000000                                                      
         backgroundcolor = #FFFFFF;                                           
      class header /                                                          
         backgroundcolor = #008000                                            
         fontfamily = "times, serif"                                          
         paddingleft = 5px                                                    
         paddingbottom = 5px                                                  
         paddingright = 5px                                                   
         paddingtop = 5px                                                     
         color = #FFFFFF                                                      
         borderleftstyle = solid                                              
         borderleftcolor = #000000                                            
         borderleftwidth = 1px                                                
         borderbottomstyle = solid                                            
         borderbottomcolor = #000000                                          
         borderbottomwidth = 1px                                              
         borderrightstyle = solid                                             
         borderrightcolor = #000000                                           
         borderrightwidth = 1px                                               
         bordertopstyle = solid                                               
         bordertopcolor = #000000                                             
         bordertopwidth = 1px;                                                
      class rowheader /                                                       
         backgroundcolor = #008000                                            
         fontfamily = "times, serif"                                          
         paddingleft = 5px                                                    
         paddingbottom = 5px                                                  
         paddingright = 5px                                                   
         paddingtop = 5px                                                     
         color = #FFFFFF                                                      
         borderleftstyle = solid                                              
         borderleftcolor = #000000                                            
         borderleftwidth = 1px                                                
         borderbottomstyle = solid                                            
         borderbottomcolor = #000000                                          
         borderbottomwidth = 1px                                              
         borderrightstyle = solid                                             
         borderrightcolor = #000000                                           
         borderrightwidth = 1px                                               
         bordertopstyle = solid                                               
         bordertopcolor = #000000                                             
         bordertopwidth = 1px;                                                
      class footer /                                                          
         backgroundcolor = #008000                                            
         fontfamily = "times, serif"                                          
         paddingleft = 5px                                                    
         paddingbottom = 5px                                                  
         paddingright = 5px                                                   
         paddingtop = 5px                                                     
         color = #FFFFFF                                                      
         borderleftstyle = solid                                              
         borderleftcolor = #000000                                            
         borderleftwidth = 1px                                                
         borderbottomstyle = solid                                            
         borderbottomcolor = #000000                                          
         borderbottomwidth = 1px                                              
         borderrightstyle = solid                                             
         borderrightcolor = #000000                                           
         borderrightwidth = 1px                                               
         bordertopstyle = solid                                               
         bordertopcolor = #000000                                             
         bordertopwidth = 1px;                                                
   
   class rowfooter /                                                       
         backgroundcolor = #A0A0A0                                            
         fontfamily = "times, serif"                                          
         paddingleft = 5px                                                    
         paddingbottom = 5px                                                  
         paddingright = 5px                                                   
         paddingtop = 5px                                                     
         color = #000000                                                      
         borderleftstyle = solid                                              
         borderleftcolor = #000000                                            
         borderleftwidth = 1px                                                
         borderbottomstyle = solid                                            
         borderbottomcolor = #000000                                          
         borderbottomwidth = 1px                                              
         borderrightstyle = solid                                             
         borderrightcolor = #000000                                           
         borderrightwidth = 1px                                               
         bordertopstyle = solid                                               
         bordertopcolor = #000000                                             
         bordertopwidth = 1px;                                                
      class data /                                                            
         fontfamily = "times, serif"                                          
         paddingleft = 5px                                                    
         paddingbottom = 5px                                                  
         paddingright = 5px                                                   
         paddingtop = 5px                                                     
         color = red                                                          
         borderleftstyle = solid                                              
         borderleftcolor = #000000                                            
         borderleftwidth = 1px                                                
         borderbottomstyle = solid                                            
         borderbottomcolor = #000000                                          
         borderbottomwidth = 1px                                              
         borderrightstyle = solid                                             
         borderrightcolor = #000000                                           
         borderrightwidth = 1px                                               
         bordertopstyle = solid                                               
         bordertopcolor = #000000                                             
         bordertopwidth = 1px;                                                
      class table /                                                           
         fontsize = 3                                                         
         borderleftstyle = solid                                              
         borderleftcolor = #000000                                            
         borderleftwidth = 1px                                                
         borderbottomstyle = solid                                            
         borderbottomcolor = #000000                                          
         borderbottomwidth = 1px                                              
         borderrightstyle = solid                                             
         borderrightcolor = #000000                                           
         borderrightwidth = 1px                                               
         bordertopstyle = solid                                               
         bordertopcolor = #000000                                             
         bordertopwidth = 1px                                                 
         borderspacing = 0                                                    
         backgroundcolor = #FFFF00;                                           
      class proctitle /                                                       
         fontweight = medium                                                  
         fontsize = 6                                                         
         fontfamily = "helvetica, sans-serif";                                
   end;                                                                       
run;                                                                         

MyCssStyle Style Applied to HTML Output

 Note about figure

[MyCssStyle Style Applied to HTML Output]

MyCssStylePrinter Style

proc template;                                                                
   define style Styles.Mycssstyleprinter / store = SASUSER.TEMPLAT;           
      parent = styles.mycssstyle;                                             
      class body /                                                            
         fontfamily = "times, serif"                                          
         color = #000000                                                      
         backgroundcolor = #FFFFFF;                                           
      class header /                                                          
         backgroundcolor = #0000FF                                            
         fontfamily = "times, serif"                                          
         paddingleft = 5px                                                    
         paddingbottom = 5px                                                  
         paddingright = 5px                                                   
         paddingtop = 5px                                                     
         color = #FFFFFF                                                      
         borderleftstyle = solid                                              
         borderleftcolor = #000000                                            
         borderleftwidth = 1px                                                
         borderbottomstyle = solid                                            
         borderbottomcolor = #000000                                          
         borderbottomwidth = 1px                                              
         borderrightstyle = solid                                             
         borderrightcolor = #000000                                           
         borderrightwidth = 1px                                               
         bordertopstyle = solid                                               
         bordertopcolor = #000000                                             
         bordertopwidth = 1px;                                                
      class rowheader /                                                       
         backgroundcolor = #0000FF                                            
         fontfamily = "times, serif"                                          
         paddingleft = 5px                                                    
         paddingbottom = 5px                                                  
         paddingright = 5px                                                   
         paddingtop = 5px                                                     
         color = #FFFFFF                                                      
         borderleftstyle = solid                                              
         borderleftcolor = #000000                                            
         borderleftwidth = 1px                                                
         borderbottomstyle = solid                                            
         borderbottomcolor = #000000                                          
         borderbottomwidth = 1px                                              
         borderrightstyle = solid                                             
         borderrightcolor = #000000                                           
         borderrightwidth = 1px                                               
         bordertopstyle = solid                                               
         bordertopcolor = #000000                                             
         bordertopwidth = 1px;                                                
      class footer /                                                          
         backgroundcolor = #0000FF                                            
         fontfamily = "times, serif"                                          
         paddingleft = 5px                                                    
         paddingbottom = 5px                                                  
         paddingright = 5px                                                   
         paddingtop = 5px                                                     
         color = #FFFFFF                                                      
         borderleftstyle = solid                                              
         borderleftcolor = #000000                                            
         borderleftwidth = 1px                                                
         borderbottomstyle = solid                                            
         borderbottomcolor = #000000                                          
         borderbottomwidth = 1px                                              
         borderrightstyle = solid                                             
         borderrightcolor = #000000                                           
         borderrightwidth = 1px                                               
         bordertopstyle = solid                                               
         bordertopcolor = #000000                                             
         bordertopwidth = 1px;                                                
      class rowfooter /                                                       
         backgroundcolor = #A0A0A0                                            
         fontfamily = "times, serif"                                          
         paddingleft = 5px                                                    
         paddingbottom = 5px                                                  
         paddingright = 5px                                                   
         paddingtop = 5px                                                     
         color = #000000                                                      
         borderleftstyle = solid                                              
         borderleftcolor = #000000                                            
         borderleftwidth = 1px                                                
         borderbottomstyle = solid                                            
         borderbottomcolor = #000000                                          
         borderbottomwidth = 1px                                              
         borderrightstyle = solid                                             
         borderrightcolor = #000000                                           
         borderrightwidth = 1px                                               
         bordertopstyle = solid                                               
         bordertopcolor = #000000                                             
         bordertopwidth = 1px;                                                
      class data /                                                            
         fontsize = 3                                                         
         fontfamily = "times, serif"                                          
         paddingleft = 5px                                                    
         paddingbottom = 5px                                                  
         paddingright = 5px                                                   
         paddingtop = 5px                                                     
         color = #000000                                                      
         borderleftstyle = solid                                              
         borderleftcolor = #000000                                            
         borderleftwidth = 1px                                                
         borderbottomstyle = solid                                            
         borderbottomcolor = #000000                                          
         borderbottomwidth = 1px                                              
         borderrightstyle = solid                                             
         borderrightcolor = #000000                                           
         borderrightwidth = 1px                                               
         bordertopstyle = solid                                               
         bordertopcolor = #000000                                             
         bordertopwidth = 1px;                                                
      class table /                                                           
         borderleftstyle = solid                                              
         borderleftcolor = #000000                                            
         borderleftwidth = 1px                                                
         borderbottomstyle = solid                                            
         borderbottomcolor = #000000                                          
         borderbottomwidth = 1px                                              
         borderrightstyle = solid                                             
         borderrightcolor = #000000                                           
         borderrightwidth = 1px                                               
         bordertopstyle = solid                                               
         bordertopcolor = #000000                                             
         bordertopwidth = 1px                                                 
         borderspacing = 0                                                    
         backgroundcolor = #DDDDDD;                                           
      class proctitle /                                                       
         fontweight = medium                                                  
         fontsize = 6                                                         
         fontfamily = "helvetica, sans-serif";                                
   end;                                                                       
run;                                                                         

MyCssStylePrinter Style Applied to PDF Output

 Note about figure

[MyCssStylePrinter Style Applied to PDF Output]

Previous Page | Next Page | Top of Page