Before you run the examples, open the zip file under the Downloads tab. Using the list below, create the folders and copy the data files so that the data are available during your SAS session.
Create the folder c:\MyRawData and copy these files to it:
Address.dat IceCreamSales.dat Shakespeare.dat Admit.dat IceCreamSales2.dat Shoe.dat AllScores.dat Lengths.dat Shoesales.dat Artists.dat Library.dat South.dat Baseball.dat LibraryBooks.dat Speed.dat Basketball.dat Mag.dat Survey.dat Boats2.dat Mens5000.dat Temperature.dat Boats.dat Mountains.dat Temps.dat Books.dat Movies.dat ToadJump.dat Bus.dat NatPark.Dat Tomatoes.dat Candy.dat NewAdmit.dat Traffic.dat Cars.dat North.dat Train.dat Choc.dat Olympic1500.dat Transpos.dat Chocolate.dat OnionRing.dat TropicalSales.dat Chocsales.dat Onions.dat UsedCars.dat Coffee.dat OrdersQ3.dat Walk.dat Criterium.dat Parks.dat WBRK.dat CustAddress.dat Picbooks.dat Zoo.dat Disc.dat Precipitation.dat Exercise.dat President.dat Bands.csv Flowers.dat Pumpkin.dat Bands2.csv Games.dat Records.dat Women.csv Garden.dat Scores.dat Home.dat SeaLife.datCreate the folder c:\MyFiles and copy this file to it: Baseball.xls
Create the folder c:\MyWebLogs and copy this file to it: dogweblogs.txt
Create the folder c:\MyExcelFiles and copy these files to it: Baseball.xls, OnionRing.xls
Create the folder c:\MyData to store files when you run examples
Create the folder c:\MyHTML to store files when you run examples
Create the folder c:\MyHTMLFiles to store files when you run examples
Create the folder c:\MyPDFFiles to store files when you run examples
Create the folder c:\MyRTFFiles to store files when you run examples
Create the folder c:\MySASLib and copy this file to it: TropicalSales.dat
Section 5.2 First Program
DATA giant; INFILE 'c:\MyRawData\Tomatoes.dat' DSD; INPUT Name :$15. Color $ Days Weight; * Trace PROC MEANS; ODS TRACE ON; PROC MEANS DATA = giant; BY Color; RUN; ODS TRACE OFF;
Second Program
PROC MEANS DATA = giant; BY Color; TITLE 'Red Tomatoes'; ODS SELECT Means.ByGroup1.Summary; RUN;
Section 5.3
DATA giant; INFILE 'c:\MyRawData\Tomatoes.dat' DSD; INPUT Name :$15. Color $ Days Weight; PROC TABULATE DATA = giant; CLASS Color; VAR Days Weight; TABLE Color ALL, (Days Weight) * MEAN; TITLE 'Standard TABULATE Output'; ODS OUTPUT Table = tabout; RUN; PROC PRINT DATA = tabout; TITLE 'OUTPUT SAS Data Set from TABULATE'; RUN;
Section 5.4
* Create the HTML files and remove procedure name; ODS HTML FILE = 'c:\MyHTMLFiles\Marine.html'; ODS NOPROCTITLE; DATA marine; INFILE 'c:\MyRawData\Sealife.dat'; INPUT Name $ Family $ Length @@; RUN; PROC MEANS DATA = marine MEAN MIN MAX; CLASS Family; TITLE 'Whales and Sharks'; RUN; PROC PRINT DATA = marine; RUN; * Close the HTML files; ODS HTML CLOSE;
Section 5.5
* Create an RTF file; ODS RTF FILE = 'c:\MyRTFFiles\Marine.rtf' BODYTITLE COLUMNS=2; ODS NOPROCTITLE; DATA marine; INFILE 'c:\MyRawData\Sealife.dat'; INPUT Name $ Family $ Length @@; RUN; PROC MEANS DATA = marine MEAN MIN MAX; CLASS Family; TITLE 'Whales and Sharks'; RUN; PROC PRINT DATA = marine; RUN; * Close the RTF file; ODS RTF CLOSE;
Section 5.6
* Create the PDF file; ODS PDF FILE = 'c:\MyPDFFiles\Marine.pdf' STARTPAGE = NO; ODS NOPROCTITLE; DATA marine; INFILE 'c:\MyRawData\Sealife.dat'; INPUT Name $ Family $ Length @@; RUN; PROC MEANS DATA = marine MEAN MIN MAX; CLASS Family; TITLE 'Whales and Sharks'; RUN; PROC PRINT DATA = marine; RUN; * Close the PDF file; ODS PDF CLOSE;
Section 5.8
First Program ODS HTML FILE='c:\MyHTML\results.htm'; DATA skating; INFILE 'c:\MyData\Women.csv' DSD MISSOVER; INPUT Year Name :$20. Country $ Time $ Record $; RUN; PROC PRINT DATA=skating; TITLE 'Women''s 5000 Meter Speed Skating'; ID Year; RUN; ODS HTML CLOSE;
Second Program ODS HTML FILE='c:\MyHTML\results2.htm'; PROC PRINT DATA=skating STYLE(DATA)={BACKGROUND=white}; TITLE 'Women''s 5000 Meter Speed Skating'; ID Year; RUN; ODS HTML CLOSE;
Third Program ODS HTML FILE='c:\MyHTML\results3.htm'; PROC PRINT DATA=skating STYLE(DATA)={BACKGROUND=white}; TITLE 'Women''s 5000 Meter Speed Skating'; VAR Name Country Time; VAR Record/STYLE(DATA)= {FONT_STYLE=italic FONT_WEIGHT=bold}; ID Year; RUN; ODS HTML CLOSE;
Section 5.9
First Program DATA skating; INFILE 'c:\MyRawData\Speed.dat' DSD; INPUT Name :$20. Country $ NumYears NumGold @@; RUN; ODS HTML FILE='c:\MyHTML\speed.htm'; PROC REPORT DATA = skating NOWINDOWS; COLUMN Country Name NumGold; DEFINE Country / GROUP; TITLE 'Olympic Women''s ' 'Speed Skating'; RUN; ODS HTML CLOSE;
Second Program * STYLE= option in PROC statement; ODS HTML FILE='c:\MyHTML\speed2.htm'; PROC REPORT DATA = skating NOWINDOWS SPANROWS STYLE(COLUMN) = {FONT_WEIGHT = bold JUST = center}; COLUMN Country Name NumGold; DEFINE Country / GROUP; TITLE 'Olympic Women''s ' 'Speed Skating'; RUN; ODS HTML CLOSE;
Third Program * STYLE= option in DEFINE statement; ODS HTML FILE='c:\MyHTML\speed3.htm'; PROC REPORT DATA = skating NOWINDOWS SPANROWS; COLUMN Country Name NumGold; DEFINE Country / GROUP STYLE(COLUMN) = {FONT_WEIGHT = bold JUST = center}; TITLE 'Olympic Women''s ' 'Speed Skating'; RUN; ODS HTML CLOSE;
Section 5.10
First Program ODS HTML FILE='c:\MyHTML\table.htm'; DATA skating; INFILE 'c:\MyData\Records.dat'; INPUT Year Event $ Record $ @@; RUN; PROC TABULATE DATA=skating; CLASS Year Record; TABLE Year='',Record*N=''; TITLE 'Men''s Speed Skating'; TITLE2 'Records Set at Olympics'; RUN; ODS HTML CLOSE;
Second Program ODS HTML FILE='c:\MyHTML\table2.htm'; PROC TABULATE DATA=skating STYLE={JUST=center BACKGROUND=white}; CLASS Year Record; TABLE Year='',Record*N=''; TITLE 'Men''s Speed Skating'; TITLE2 'Records Set at Olympics'; RUN; ODS HTML CLOSE;
Section 5.11
First Program ODS HTML FILE='c:\MyHTML\mens.html'; DATA results; INFILE 'c:\MyRawData\Mens5000.dat' DSD; INPUT Place Name :$20. Country :$15. Time ; RUN; PROC PRINT DATA=results; ID Place; TITLE 'Men''s 5000m Speed Skating'; TITLE2 '2002 Olympic Results'; RUN; ODS HTML CLOSE;
Second Program ODS HTML FILE='c:\MyHTML\mens2.html'; PROC FORMAT; VALUE rec 0 -< 378.72 ='red' 378.72 -< 382.20 = 'orange' 382.20 - HIGH = 'white'; RUN; PROC PRINT DATA=results; ID Place; VAR Name Country; VAR Time/STYLE={BACKGROUND=rec.}; TITLE 'Men''s 5000m Speed Skating'; TITLE2 '2002 Olympic Results'; RUN; ODS HTML CLOSE;
The sample is authored by Lora D. Delwiche and Susan J. Slaughter.
Their book The Little SAS Book: A Primer, Fourth Edition is available for sale in our online bookstore.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
Section 5.2, OutputSection 5.3, Output
Section 5.4, Output
Section 5.5, Output
Section 5.6, Output
Section 5.8, Output
Section 5.9, Output
Section 5.10, Output
Section 5.11, Output
Type: | Sample |
Date Modified: | 2009-01-29 17:18:00 |
Date Created: | 2009-01-09 15:23:53 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | Base SAS | z/OS | ||
OpenVMS VAX | ||||
Microsoft® Windows® for 64-Bit Itanium-based Systems | ||||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | ||||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | ||||
Microsoft Windows XP 64-bit Edition | ||||
Microsoft® Windows® for x64 | ||||
OS/2 | ||||
Microsoft Windows 95/98 | ||||
Microsoft Windows 2000 Advanced Server | ||||
Microsoft Windows 2000 Datacenter Server | ||||
Microsoft Windows 2000 Server | ||||
Microsoft Windows 2000 Professional | ||||
Microsoft Windows NT Workstation | ||||
Microsoft Windows Server 2003 Datacenter Edition | ||||
Microsoft Windows Server 2003 Enterprise Edition | ||||
Microsoft Windows Server 2003 Standard Edition | ||||
Microsoft Windows XP Professional | ||||
Windows Millennium Edition (Me) | ||||
Windows Vista | ||||
64-bit Enabled AIX | ||||
64-bit Enabled HP-UX | ||||
64-bit Enabled Solaris | ||||
ABI+ for Intel Architecture | ||||
AIX | ||||
HP-UX | ||||
HP-UX IPF | ||||
IRIX | ||||
Linux | ||||
Linux for x64 | ||||
Linux on Itanium | ||||
OpenVMS Alpha | ||||
OpenVMS on HP Integrity | ||||
Solaris | ||||
Solaris for x64 | ||||
Tru64 UNIX |