SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Setting Up Your SAS Session
Lesson Summary

This page contains


I. Text Summary

To go to the page where a task, programming feature, or concept was presented, select a link.


Referencing SAS Files in SAS Libraries
To reference a SAS file, you assign a libref (library reference) to the SAS library where the file is stored. Then you use the libref as the first part of the two-level name (libref.filename) for the file. To reference a SAS library, you can submit a LIBNAME statement. You can store the LIBNAME statement with any SAS program to reference the SAS library automatically when you submit the program. The LIBNAME statement assigns the libref for the current SAS session only. You must assign a libref each time you begin a SAS session in order to access SAS files stored in a permanent SAS library. (Work is the default libref for a temporary SAS library.)

You can also use the LIBNAME statement to reference data in files formatted by other software products, such as database management systems. SAS software can write to or read from the files by means of the appropriate engine for that file type. (A SAS engine is a set of internal instructions that SAS uses for writing to and reading from files in a SAS library.) For some file types, you need to tell SAS software which engine to use. For others, SAS software automatically chooses the appropriate engine.

Viewing Librefs
The librefs in effect for your SAS session are listed under Libraries in the Explorer window. To view details about a library, double-click Libraries (or select Libraries and then Open from the pop-up menu). Then select View Details. The library's name, engine, host pathname, and date are listed under Active Libraries.

Viewing a Library's Contents
To view the contents of a library, double-click the library name in the Explorer window (or select the library name and then Open from the pop-up menu). Files contained in the library are listed under Contents.

Viewing a File's Contents
Under Contents in the Explorer window, you can display the contents of a file by double clicking the filename (or selecting the filename and then Open from the pop-up menu). If you select a SAS data set, its contents are displayed in the VIEWTABLE window.

Specifying Results Formats
In desktop operating environments, you can choose to create your SAS procedure output as an HTML document, a listing (traditional SAS output), or both. You choose the results format(s) that you prefer in the Preferences window. Your preferences are saved until you modify them, and they apply to all output created during your SAS session. To open this window, select Tools ---> Options ---> Preferences. Then click the Results tab. Choose Listing, HTML, or both.  

If you choose HTML, each HTML file is displayed in the browser that you specify (in the Windows operating environment, the internal browser is the Results Viewer window). HTML files are stored in the location that you specify and are incrementally named sashtml.htm, sashtml1.htm, sashtml2.htm, and so on throughout your SAS session. To specify where HTML files are stored, type a path in the Folder box (or click Browse to locate a pathname). If you prefer to store your HTML files temporarily and delete them at the end of your SAS session, click Use WORK folder instead of specifying a folder. To specify the presentation style for HTML output, you can select an item in the Style box.

Setting System Options
For your listing output, you can also control the appearance of your output by setting system options such as line size, page size, the display of page numbers, and the display of date and time. (These options do not affect the appearance of HTML output.)

All SAS system options have default settings that are used unless you specify otherwise. For example, page numbers are automatically displayed (unless your site modifies this default). To modify system options, you submit an OPTIONS statement. You can place an OPTIONS statement anywhere in a SAS program to change the current settings. Because the OPTIONS statement is global, the settings remain in effect until you modify them or end your SAS session.

If you use two-digit year values in your SAS data lines, you must be aware of the YEARCUTOFF= option to ensure that you are properly interpreting two-digit years in your SAS program. This option specifies which 100-year span is used to interpret two-digit year values.

The SAS System Options Window
You can also set system options using the SAS System Options window. However, you cannot store the option settings with your SAS programs as you can using the OPTIONS statement.


II. Syntax

To go to the page where a statement or option was presented, select a link.

LIBNAME libref 'SAS-data-library';
LIBNAME libref engine 'SAS-data-library';
OPTIONS options;
PROC or DATA step goes here
RUN;


III. Sample Program (in the Windows environment)
     options pagesize=54 linesize=76 pageno=10 
             yearcutoff=1925;
     libname acctqtr3 'd:\users\qtr\reports';
     proc print data=acctqtr3.sales;
     run;
     libname rptdata spss 'g:\patients\reports.dat';
     proc print data=rptdata.new_tests;
     run;


IV. Points to Remember
  • LIBNAME and OPTIONS statements remain in effect for the current SAS session only.

  • When you specify librefs or system options by using SAS windows, you cannot store the specifications in your SAS programs as you can by using the LIBNAME and OPTIONS statements.

  • When you work with date values,
    • check the default value of the YEARCUTOFF= system option and change it if necessary
    • specify the proper informat for reading a date value or the proper format for writing a date value
    • specify the correct field width so that the entire date value is read or written.



back||next

 

Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement