UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

SAS Code Fragment
Making a Custom Web Page in SAS

SAS has the ability to make web pages with built in macros, but this shows how to make a custom web page
from a SAS data file.
data _null_;
 
  set myfile END=lastvar;  /* put in END=lastvar to know when at end of file */

  file 'c:\wwfile.htm';    /* you can change this to whatever you like */


  if _N_ = 1 then 
  do;
    * PUT TOP OF WEB PAGE HERE ;
    put '<HTML><BODY>';
    put '<table align=center width=600 cellpadding="1" style="border=thin" cellspacing="0" border=1>';
    put '<TR>';
    put '<TH BGCOLOR=#FFFFE0 ALIGN="CENTER" VALIGN="MIDDLE"><STRONG><FONT FACE=arial COLOR=NAVY SIZE="-3"> Patients </FONT></STRONG></TH>'; 
    put '<TH BGCOLOR=#FFFFE0 ALIGN="CENTER" VALIGN="MIDDLE"><STRONG><FONT FACE=arial COLOR=NAVY SIZE="-3"> Dept </FONT></STRONG></TH>'; 
    put '<TH BGCOLOR=#FFFFE0 ALIGN="CENTER" VALIGN="MIDDLE"><STRONG><FONT FACE=arial COLOR=NAVY SIZE="-3"> Unit </FONT></STRONG></TH>'; 
    put '<TH BGCOLOR=#FFFFE0 ALIGN="CENTER" VALIGN="MIDDLE"><STRONG><FONT FACE=arial COLOR=NAVY SIZE="-3"> Accom </FONT></STRONG></TH>'; 
    put '<TH BGCOLOR=#FFFFE0 ALIGN="CENTER" VALIGN="MIDDLE"><STRONG><FONT FACE=arial COLOR=NAVY SIZE="-3"> Rm Bd </FONT></STRONG></TH>'; 
    put '<TH BGCOLOR=#FFFFE0 ALIGN="CENTER" VALIGN="MIDDLE"><STRONG><FONT FACE=arial COLOR=NAVY SIZE="-3"> Phys </FONT></STRONG></TH>';
    put '<TH BGCOLOR=#FFFFE0 ALIGN="CENTER" VALIGN="MIDDLE"><STRONG><FONT FACE=arial COLOR=NAVY SIZE="-3"> Serv </FONT></STRONG></TH>';
    put '<TH BGCOLOR=#FFFFE0 ALIGN="CENTER" VALIGN="MIDDLE"><STRONG><FONT FACE=arial COLOR=NAVY SIZE="-3"> Team </FONT></STRONG></TH>';
    put '<TH BGCOLOR=#FFFFE0 ALIGN="CENTER" VALIGN="MIDDLE"><STRONG><FONT FACE=arial COLOR=NAVY SIZE="-3"> Payor </FONT></STRONG></TH>';
    put '<TH BGCOLOR=#FFFFE0 ALIGN="CENTER" VALIGN="MIDDLE"><STRONG><FONT FACE=arial COLOR=NAVY SIZE="-3"> LOS </FONT></STRONG></TH>';
    put '<TH BGCOLOR=#FFFFE0 ALIGN="CENTER" VALIGN="MIDDLE"><STRONG><FONT FACE=arial COLOR=NAVY SIZE="-3"> Age </FONT></STRONG></TH>';
    put '<TH BGCOLOR=#FFFFE0 ALIGN="CENTER" VALIGN="MIDDLE"><STRONG><FONT FACE=arial COLOR=NAVY SIZE="-3"> Gen </FONT></STRONG></TH>';
    put '</TR>';
  end;

  * set color for males and females.  Males blue, females pink ;
  * you can change this to whatever you like ;
  if Gender="M" then color = '"#000080"' ;
  if Gender="F" then color = '"#FF00FF"' ;

  put '<TR>';
  put '<TD  BGCOLOR=#FFFFE0 ALIGN="CENTER" VALIGN="MIDDLE"><B><FONT FACE=arial COLOR=NAVY size="1">' newpatid '</FONT></B></TD>';
  * Note the color is used here, and the dept color depends on the gender ;
  put '<TD  ALIGN="CENTER" VALIGN="MIDDLE"><STRONG><FONT FACE=arial  SIZE="-3" color=' color '>' Dept '</FONT></STRONG></TD>';
  put '<TD  ALIGN="CENTER" VALIGN="MIDDLE"><STRONG><FONT FACE=arial  SIZE="-3">' Unit '</FONT></STRONG></TD>';
  put '<TD  ALIGN="CENTER" VALIGN="MIDDLE"><STRONG><FONT FACE=arial  SIZE="-3">'Accom '</FONT></STRONG></TD>';
  put '<TD  ALIGN="CENTER" VALIGN="MIDDLE"><STRONG><FONT FACE=arial  SIZE="-3">'Roombed '</FONT></STRONG></TD>';
  put '<TD  ALIGN="CENTER" VALIGN="MIDDLE"><STRONG><FONT FACE=arial  SIZE="-3">' docid '</FONT></STRONG></TD>';
  put '<TD  ALIGN="CENTER" VALIGN="MIDDLE"><STRONG><FONT FACE=arial  SIZE="-3">' Service '</FONT></STRONG></TD>';
  put '<TD  ALIGN="CENTER" VALIGN="MIDDLE"><STRONG><FONT FACE=arial  SIZE="-3">' Team '</FONT></STRONG></TD>';
  put '<TD  ALIGN="CENTER" VALIGN="MIDDLE"><STRONG><FONT FACE=arial  SIZE="-3">'Payor'</FONT></STRONG></TD>';
  put '<TD  ALIGN="CENTER" VALIGN="MIDDLE"><STRONG><FONT FACE=arial  SIZE="-3">'LOS '</FONT></STRONG></TD>';
  put '<TD  ALIGN="CENTER" VALIGN="MIDDLE"><STRONG><FONT FACE=arial  SIZE="-3">'Age '</FONT></STRONG></TD>';
  put '<TD  ALIGN="CENTER" VALIGN="MIDDLE"><STRONG><FONT FACE=arial  SIZE="-3">'Gender /'</FONT></STRONG></TD>';
  put '</FONT>';
  put '</TR>';

  if lastvar then 
  do;
    * put the footer information for the web page here. ;
    put '</table>';
    put '<HTML><BODY>';
  end;
run;

 


How to cite this page

Report an error on this page

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California