SUPPORT / SAMPLES & SAS NOTES
 

Support

Sample 34630: Coming to SAS from SQL

DetailsOutputDownloadsAboutRate It
These examples appear in Appendix D of The Little SAS Book: A Primer, Fourth Edition.

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.dat                                     
                                                                       
 
Create 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


Program (page 327)

LIBNAME sports 'c:\MySASLib';
PROC SQL;
   CREATE TABLE sports.customer
      (CustomerNumber num,
       Name           char(17),
       Address        char(20));

   INSERT INTO sports.customer
      VALUES (101, 'Murphy''s Sports ', '115 Main St.        ')
      VALUES (102, 'Sun N Ski        ', '2106 Newberry Ave.  ')
      VALUES (103, 'Sports Outfitters', '19 Cary Way         ')
      VALUES (104, 'Cramer & Johnson ', '4106 Arlington Blvd.')
      VALUES (105, 'Sports Savers    ', '2708 Broadway      ');

   TITLE 'The Sports Customer Data';
   SELECT *
      FROM sports.customer;


Program (page 328)

LIBNAME sports 'c:\MySASLib';
DATA sports.customer;
   INPUT CustomerNumber Name $ 5-21 Address $ 23-42;
   DATALINES;
101 Murphy's Sports   115 Main St.
102 Sun N Ski         2106 Newberry Ave.
103 Sports Outfitters 19 Cary Way
104 Cramer & Johnson  4106 Arlington Blvd.
105 Sports Savers     2708 Broadway
   ;
PROC PRINT DATA = sports.customer;
TITLE 'The Sports Customer Data';
RUN;


First Program (page 329)

LIBNAME sports 'c:\MySASLib';
PROC SQL;
   TITLE 'Customer Number 102';
   SELECT *
      FROM sports.customer
      WHERE CustomerNumber = 102;
Second Program (page 329)
LIBNAME sports 'c:\MySASLib';
DATA sunnski;
   SET sports.customer;
   IF CustomerNumber = 102;
PROC PRINT DATA = sunnski;
   TITLE 'Customer Number 102';
RUN;


Program (page 331)

LIBNAME sports 'c:\MySASLib';
DATA outfitters;
   SET sports.customer;
   IF Name = 'Sports Outfitters';
PROC PRINT DATA = outfitters;
RUN;


First Program (page 332)

LIBNAME sports 'c:\MySASLib';
DATA outfitters;
   SET sports.customer;
   WHERE Name = 'Sports Outfitters';
PROC PRINT DATA = outfitters;
RUN;
Second Program (page 332)
LIBNAME sports 'c:\MySASLib';
DATA outfitters (WHERE = (Name = 'Sports Outfitters'));
   SET sports.customer;
PROC PRINT DATA = outfitters;
RUN;
Third Program (page 332)
LIBNAME sports 'c:\MySASLib';
PROC PRINT DATA = sports.customer;
   WHERE Name = 'Sports Outfitters';
RUN;


Program (page 333)

LIBNAME sports 'c:\MySASLib';
PROC PRINT DATA = sports.customer (WHERE = (Name = 'Sports Outfitters'));
RUN;


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.