Chapter 2. Referencing Files and Setting Options

Overview

Introduction

When you begin a SAS session, it's often convenient to set up your environment first. For example, you may want to

  • define libraries that contain the SAS data sets that you intend to use

  • specify whether your procedure output is created as an HTML (Hyper Text Markup Language) document, a SAS listing, or both

  • set features of your SAS listings, such as whether the date and time appear

  • specify how two-digit year values should be interpreted.

This chapter shows you how to define libraries, reference SAS files, and specify options for your SAS session. You also learn how to specify the form(s) of output to produce.

Introduction

Objectives

In this chapter, you learn to

  • define new libraries by using programming statements

  • reference SAS files to be used during your SAS session

  • set results options to determine the type of output produced (HTML, SAS listings, or both) in desktop operating environments

  • set system options to determine how date values are read and to control the appearance of listing output that is created during your SAS session.

Defining Libraries

Often the first step in setting up your SAS session is to define the libraries. In "Using the Programming Workspace" on page 18, you learned to use SAS windows to assign library names. You can also use programming statements to assign library names.

Remember that to reference a permanent SAS file, you

  1. assign a name (libref) to the SAS library in which the file is stored

  2. use the libref as the first part of the file's two-level name (libref.filename)to reference the file within the library.

Defining Libraries

Assigning Librefs

To define libraries, you can use a LIBNAME statement. You can store the LIBNAME statement with any SAS program so that the SAS data library is assigned each time the program is submitted.

The LIBNAME statement below assigns the libref Clinic to the SAS data library D:UsersQtrReports in the Windows environment.

libname clinic 'd:usersqtr
eports';

The table below gives some examples of physical names for SAS data libraries in various operating environments.

EnvironmentSample Physical Name
Windowsc:fitnessdata
UNIX/users/april/fitness/sasdata
Open VMSdua0:[april.fitness]
CMSb
z/OS (OS/390)april.fitness.sasdata
Assigning Librefs

You can use multiple LIBNAME statements to assign as many librefs as needed.

Verifying Librefs

After assigning a libref, it is a good idea to check the Log window to verify that the libref has been assigned successfully.

Verifying Librefs

How Long Librefs Remain in Effect

The LIBNAME statement is global, which means that the librefs remain in effect until you modify them, cancel them, or end your SAS session.

Therefore, the LIBNAME statement assigns the libref for the current SAS session only. Each time you begin a SAS session, you must assign a libref to each permanent SAS data library that contains files that you want to access in that session. (Remember that Work is the default libref for a temporary SAS data library.)

How Long Librefs Remain in Effect

When you end your SAS session or delete a libref, SAS no longer has access to the files in the library. However, the contents of the library still exist on your operating system.

How Long Librefs Remain in Effect

Specifying Two-Level Names

After you assign a libref, you specify it as the first element in the two-level name for a SAS file.

Specifying Two-Level Names

For example, in order for the PRINT procedure to read Clinic.Admit, you specify the two-level name of the file as follows:

proc print data=clinic.admit;
run;

Referencing Files in Other Formats

You can use the LIBNAME statement to reference not only SAS files but also files that were created with other software products, such as database management systems.

SAS can read or write these files by using the appropriate engine for that file type. For some file types, you need to tell SAS which engine to use. For others, SAS automatically chooses the appropriate engine.

Referencing Files in Other Formats

Specifying Engines

To indicate which engine to use, you specify the engine name in the LIBNAME statement, as shown below.

Interface Library Engines

Interface library engines support read-only access to BMDP, OSIRIS, and SPSS files. With these engines, the physical filename that is associated with a libref is an actual filename, not a SAS library. This is an exception to the rules for librefs.

EngineDescription
BMDPallows read-only access to BMDP files
OSIRISallows read-only access to OSIRIS files
SPSSallows read-only access to SPSS files

For example, the LIBNAME statement below specifies the libref Rptdata and the engine SPSS for the file G:Myspss.dat in the Windows operating environment.

libname rptdata spss 'g:myspss.dat';

For more information about interface library engines, see the SAS documentation for your operating environment.

SAS/ACCESS Engines

If your site licenses SAS/ACCESS software, you can use the LIBNAME statement to access data that is stored in a DBMS file. The types of data you can access depend on your operating environment and on which SAS/ACCESS products you have licensed.

Relational DatabasesNonrelational FilesPC Files
ORACLEADABASExcel (.xls)
SYBASEIMS/DL-ILotus (.wkn)
InformixCA-IDMSDBF
DB2 for z/OSSYSTEM 2000DIF
DB2 for UNIX and PC  
Oracle Rdb  
ODBC  
CA-OpenIngres  

Viewing SAS Libraries

Viewing the Contents of a SAS Library

You've seen that you can assign librefs in order to access different types of data. If you completed "Using the Programming Workspace" on page 18, you know that after you have assigned a libref, you can view

  • details about the library that the libref references

  • the library's contents

  • contents and properties of files in the library.

The libraries that are currently defined for your SAS session are listed under Libraries in the Explorer window. To view details about a library, double-click Libraries (or select Libraries

Viewing the Contents of a SAS Library
Open from the pop-up menu). Then select View
Viewing the Contents of a SAS Library
Details
.

Information for each library (name, engine, type, host pathname, and date modified) is listed under Active Libraries.

Viewing the Contents of a SAS Library

To view the contents of a library, double-click the library name (or select the library name, and then select Open from the pop-up menu). A list of the files contained in the library is displayed. If you have the details feature turned on, then information about each file (name, size, type, description, and date modified) is also listed.

Viewing the Contents of a SAS Library

Viewing a File's Contents

To display a file's contents in a windowing environment, you can double-click the filename (or select the filename, and then select Open from the pop-up menu). If you select a SAS data set (type Table or View), its contents are displayed in the VIEWTABLE window.

Viewing a File's Contents

To display a file's properties, you can select the filename, and then select Properties from the pop-up menu.

Viewing a File's Contents

If you have installed SAS/FSP software, you can type B or L in the selection field next to a data set name to browse the data set observation by observation or to list the contents of the data set, respectively. For more information, see the documentation for SAS/FSP.

If SAS/FSP is not installed, you can view the contents of a SAS data set by using the PRINT procedure (PROC PRINT). You can learn how to use PROC PRINT in Chapter 4, "Creating List Reports," on page 99.

Viewing the Contents of a SAS Library

You've learned how to use SAS windows to view the contents of a SAS library or of a SAS file. Alternatively, you can use the CONTENTS procedure to create SAS output that describes either of the following:

  • the contents of a library

  • the descriptor information for an individual SAS data set.

Examples

To view the contents of the entire Mylib library, you can submit the following PROC CONTENTS step:

proc contents data=mylib._all_ nods;
run;

The output from this step lists only the names, types, sizes, and modification dates for the SAS files in the Mylib library.

Examples

To view only the descriptor information for the Mylib.Admit data set, you can submit the following PROC CONTENTS step:

proc contents data=mylib.admit;
run;

The output from this step lists information for Mylib.Admit, including an alphabetic list of the variables in the data set.

Examples
Examples

Using PROC DATASETS

In addition to PROC CONTENTS, you can also use PROC DATASETS to view the contents of a SAS library or a SAS data set. PROC DATASETS also enables you to perform a number of management tasks such as copying, deleting, or modifying SAS files.

PROC CONTENTS and PROC DATASETS overlap in terms of functionality. Generally, these two function the same:

  • the CONTENTS procedure

  • the CONTENTS statement in the DATASETS procedure.

PROC CONTENTS<options>;         PROC DATASETS<options>;

RUN;                                                              CONTENTS<options>;

                                                                QUIT;

The major difference between the CONTENTS procedure and the CONTENTS statement in PROC DATASETS is the default for libref in the DATA= option. For PROC CONTENTS, the default is either Work or User. For the CONTENTS statement, the default is the libref of the procedure input library. Notice also that PROC DATASETS is an interactive procedure that requires a QUIT statement rather than a RUN statement.

However, the options for the PROC CONTENTS statement and the CONTENTS statement in the DATASETS procedure are the same. For example, the following PROC steps produce essentially the same output (with minor formatting differences):

proc datasets;
   contents data=sasuser._all_ nods;
quit;

proc contents data=sasuser._all_ nods;
run;
Using PROC DATASETS

Viewing Descriptor Information for a SAS Data Set Using VARNUM

As with PROC CONTENTS, you can also use PROC DATASETS to display the descriptor information for a specific SAS data set.

By default, PROC CONTENTS and PROC DATASETS list variables alphabetically. To list variable names in the order of their logical position (or creation order) in the data set, you can specify the VARNUM option in PROC CONTENTS or in the CONTENTS statement in PROC DATASETS.

For example, either of these programs creates output that includes the list of variables shown below:

proc datasets;
   contents data=sasuser.admit varnum;
quit;

proc contents data=sasuser.admit varnum;
run;
Viewing Descriptor Information for a SAS Data Set Using VARNUM

Specifying Results Formats

Next, let's consider the appearance and format of your SAS output. You can specify result formats to create your output as

  • an HTML document

  • a listing (traditional SAS output)

  • both of the above.

You can create HTML output using programming statements on any SAS platform. In addition, in desktop operating environments, you can use windows to specify result formats.

Let's look at the two result formats. For example, the following PROC PRINT output is a listing of part of the SAS data set Clinic.Therapy:

Specifying Results Formats

This is HTML output from the same program:

Specifying Results Formats
Specifying Results Formats

The Results Tab of the Preferences Window

You use the Preferences window to set the result format(s) that you prefer. Your preferences are saved until you modify them, and they apply to all output that you create.

To open this window in desktop operating environments, select Tools

The Results Tab of the Preferences Window
Options
The Results Tab of the Preferences Window
Preferences
. Then click the Results tab. You can choose Listing, HTML, or both. You can also specify options for displaying and storing your results.

The Results Tab of the Preferences Window
The Results Tab of the Preferences Window

If you create HTML files, they are stored in the folder that you specify and are incrementally named sashtml.htm, sashtml1.htm, sashtml2.htm, and so on, throughout your SAS session.

Now look at the two choices for viewing HTML results: Internal browser and Preferred web browser. (These options appear in the Results tab only in the Windows operating environment.)

Internal Browser vs. Preferred Web Browser

To view HTML output, you can choose between these two options in the Results tab of the Preferences window in the Windows operating environment:

  • the Internal browser, called the Results Viewer window. SAS provides this browser as part of your SAS installation.

  • the Preferred web browser. If you select this option, SAS uses the browser that is specified in the Web tab of the Preferences window. By default, this is the default browser for your PC.

Internal Browser

The Results Viewer is displayed as a SAS window, as shown below.

Internal Browser
Internal Browser

Preferred Web Browser

If you select the preferred web browser, your HTML output is displayed in a separate browser that is independent of SAS. For example, the HTML output below is displayed in Microsoft Internet Explorer.

Preferred Web Browser

Setting System Options

If you create your procedure output as a SAS listing, you can also control the appearance of your output by setting system options such as

  • line size (the maximum width of the log and output)

  • page size (the number of lines per printed page of output)

  • the display of page numbers

  • the display of date and time.

Setting System Options

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).

Setting System Options

To modify system options, you submit an OPTIONS statement. You can place an OPTIONS statement anywhere in a SAS program to change the settings from that point onward. However, it is good programming practice to place OPTIONS statements outside of DATA or PROC steps so that your programs are easier to read and debug.

Because the OPTIONS statement is global, the settings remain in effect until you modify them, or until you end your SAS session.

Example: DATE | NODATE and NUMBER | NONUMBER Options

By default, page numbers and dates appear with output. The following OPTIONS statement suppresses the printing of both page numbers and the date and time in listing output.

options nonumber nodate;

In the following example, page numbers and the current date are not displayed in the PROC PRINT output. Page numbers are not displayed in the PROC FREQ output, either, but the date does appear at the top of the page that contains the PROC FREQ report.

options nonumber nodate;
proc print data=clinic.admit;
   var id sex age height weight;
   where age>=30;
run;
options date;
proc freq data=clinic.diabetes;
 
   where fastgluc>=300;
   tables sex;
run;
Example: DATE | NODATE and NUMBER | NONUMBER Options

Example: PAGENO= Option

If you print page numbers, you can specify the beginning page number for your report by using the PAGENO= option. If you don't specify PAGENO=, output is numbered sequentially throughout your SAS session, starting with page 1.

In the following example, the output pages are numbered sequentially throughout the SAS session, beginning with number 3.

options nodate number pageno=3;
proc print data=hrd.funddrv;
run;
Example: PAGENO= Option

Example: PAGESIZE= Option

The PAGESIZE= option specifies how many lines each page of output contains. In the following example, each page of the output that the PRINT procedure produces contains 15 lines (including those used by the title, date, and so on).

options number pagesize=15;
proc print data=clinic.admit;
run;
Example: PAGESIZE= Option

Example: LINESIZE= Option

The LINESIZE= option specifies the width of the print line for your procedure output and log. Observations that do not fit within the line size continue on a different line.

In the following example, the observations are longer than 64 characters, so the observations continue on a subsequent page.

options number linesize=64;
proc print data=flights.europe;
run;
Example: LINESIZE= Option

Handling Two-Digit Years: Year 2000 Compliance

If you use two-digit year values in your data lines, external files, or programming statements, you should consider another important system option, the YEARCUTOFF= option. This option specifies which 100-year span is used to interpret two-digit year values.

Handling Two-Digit Years: Year 2000 Compliance

All versions of SAS represent dates correctly from 1582 A.D. to 20,000 A.D. (Leap years, century, and fourth-century adjustments are made automatically. Leap seconds are ignored, and SAS does not adjust for Daylight Savings Time.) However, you should be aware of the YEARCUTOFF= value to ensure that you are properly interpreting two-digit years in data lines.

As with other system options, you specify the YEARCUTOFF= option in the OPTIONS statement:

options yearcutoff=1925;

How the YEARCUTOFF= Option Works

When a two-digit year value is read, SAS interprets it based on a 100-year span which starts with the YEARCUTOFF= value. The default value of YEARCUTOFF= is 1920.

How the YEARCUTOFF= Option Works
Date ExpressionInterpreted As
12/07/4112/07/1941
18Dec1518Dec2015
04/15/3004/15/1930
15Apr9515Apr1995

However, you can override the default and change the value of YEARCUTOFF= to the first year of another 100-year span. For example, if you specify YEARCUTOFF=1950, then the 100-year span will be from 1950 to 2049.

options yearcutoff=1950;

Using YEARCUTOFF=1950, dates are interpreted as shown below:

How the YEARCUTOFF= Option Works
Date ExpressionInterpreted As
12/07/4112/07/1941
18Dec1518Dec2015
04/15/3004/15/2030
15Apr9515Apr1995

How Four-Digit Years Are Handled

Remember, the value of the YEARCUTOFF= system option affects only two-digit year values. A date value that contains a four-digit year value will be interpreted correctly even if it does not fall within the 100-year span set by the YEARCUTOFF=system option.

You can learn more about reading date values in Chapter 19, "Reading Date and Time Values," on page 581.

Using System Options to Specify Observations

You've seen how to use SAS system options to change the appearance of output and interpret two-digit year values. You can also use the FIRSTOBS= and OBS= system options to specify the observations to process from SAS data sets.

You can specify either or both of these options as needed. That is, you can use

  • FIRSTOBS= to start processing at a specific observation

  • OBS= to stop processing after a specific observation

  • FIRSTOBS= and OBS= together to process a specific group of observations.

Examples: FIRSTOBS= and OBS= Options

The data set Sasuser.Heart contains 20 observations. If you specify FIRSTOBS=10, SAS reads the 10th observation of the data set first and reads through the last observation (for a total of 11 observations).

options firstobs=10;
proc print data=sasuser.heart;
run;

The PROC PRINT step produces the following output:

Examples: FIRSTOBS= and OBS= Options

If you specify OBS=10 instead, SAS reads through the 10th observation, in this case for a total of 10 observations. (Notice that FIRSTOBS= has been reset to the default value.)

options firstobs=1 obs=10;
proc print data=sasuser.heart;
run;

Now the PROC PRINT step produces this output:

Examples: FIRSTOBS= and OBS= Options

Combining FIRSTOBS= and OBS= processes observations in the middle of the data set. For example, the following program processes only observations 10 through 15, for a total of 6 observations:

options firstobs=10 obs=15;
proc print data=sasuser.heart;
run;

Here is the output:

Examples: FIRSTOBS= and OBS= Options

To reset the number of the last observation to process, you can specify OBS=MAX in the OPTIONS statement.

options obs=max;

This instructs any subsequent SAS programs in the SAS session to process through the last observation in the data set being read.

Using FIRSTOBS= and OBS= for Specific Data Sets

As you saw above, using the FIRSTOBS= or OBS= system options determines the first or last observation, respectively, that is read for all steps for the duration of your current SAS session or until you change the setting. However, you may want to

  • override these options for a given data set

  • apply these options to a specific data set only.

To affect any single file, you can use FIRSTOBS= or OBS= as data set options instead of as system options. You specify the data set option in parentheses immediately following the input data set name.

Using FIRSTOBS= and OBS= for Specific Data Sets

Example: FIRSTOBS= and OBS= as Data Set Options

As shown in the last example above, this program processes only observations 10 through 15, for a total of 6 observations:

options firstobs=10 obs=15;
proc print data=sasuser.heart;
run;

You can create the same output by specifying FIRSTOBS= and OBS= as data set options, as follows. The data set options override the system options for this instance only.

options firstobs=10 obs=15;
proc print data=sasuser.heart(firstobs=10 obs=15);
run;

To specify FIRSTOBS= or OBS= for this program only, you could omit the OPTIONS statement altogether and simply use the data set options.

The SAS System Options Window

You can also set system options by using the SAS System Options window. However, you cannot store the option settings in your SAS programs as you can when you use the OPTIONS statement.

To view the SAS System Options window, select Tools

The SAS System Options Window
Options
The SAS System Options Window
System
.

The SAS System Options Window

Changing Options

To change an option:

  1. Expand the groups and subgroups under SAS Options Environment until you find the option that you want to change. (Options in subgroups are listed in the right pane of the window.)

  2. Click the name of the option that you want to change, and display its pop-up menu. Then select one of the choices:

    • Modify Value opens a window in which you type or select a new value for the option.

    • Set to Default immediately resets the option to its default value.

For example, the SAS System Options window above shows options for the SAS log and procedure output subgroup under the group Log and procedure output control.

Finding Options Quickly

To locate an option in the SAS System Options window:

  1. Place your cursor over the name of any option group or subgroup, and display its pop-up menu.

  2. Click Find Option. The Find Option dialog box appears.

  3. Type the name of the option that you want to locate, and click OK.

The SAS System Options window expands to the appropriate option subgroup. All subgroup options also appear, and the option that you located is highlighted.

Additional Features

When you set up your SAS session, you can set SAS system options that affect listing output, information written to the SAS log, and much more. Here are some additional system options that you are likely to use with SAS procedures:

FORMCHAR= 'formatting-characters'specifies the formatting characters for your output device. Formatting characters are used to construct the outlines of tables as well as dividers for various procedures, such as the FREQ and TABULATE procedures. If you do not specify formatting characters as an option in the procedure, then the default specifications given in the FORMCHAR= system option are used.
FORMDLIM= 'delimit-character'specifies a character that is used to delimit page breaks in SAS System output. Normally, the delimit character is null. When the delimit character is null, a new physical page starts whenever a page break occurs.
LABEL|NOLABELpermits SAS procedures to temporarily replace variable names with descriptive labels. The LABEL system option must be in effect before the LABEL option of any procedure can be used. If NOLABEL is specified, then the LABEL option of a procedure is ignored. The default setting is LABEL.
REPLACE|NOREPLACEspecifies whether permanently stored SAS data sets are replaced. If you specify NOREPLACE, a permanently stored SAS data set cannot be replaced with one that has the same name. This prevents you from inadvertently replacing existing SAS data sets. The default setting is REPLACE.
SOURCE|NOSOURCEcontrols whether SAS source statements are written to the SAS log. NOSOURCE specifies not to write SAS source statements to the SAS log. The default setting is SOURCE.

You can also use programming statements to control the result format of each item of procedure output individually. For more information, see Chapter 10, "Producing HTML Output," on page 293.

Chapter Summary

Text Summary

Referencing SAS Files in SAS Libraries

To reference a SAS file, you assign a libref (library reference) to the SAS library in which 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 that are 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 that were created with other software products, such as database management systems. SAS can write to or read from the files by using the appropriate engine for that file type. For some file types, you need to tell SAS which engine to use. For others, SAS automatically chooses the appropriate engine.

Viewing Librefs

The librefs that are 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

Viewing Librefs
Open from the pop-up menu). Then select View
Viewing Librefs
Details
. The library's name, engine, host pathname, and date are listed under Active Libraries.

Viewing the Contents of a Library

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

Viewing the Contents of a File

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

If you are working in the z/OS (OS/390) or CMS operating environment, you can type ? in the selection field next to a filename in the Explorer window to display a pop-up menu with a list of options for working with that file.

Listing the Contents of a Library

To list the contents of a library, use the CONTENTS procedure. Append a period and the _ALL_ option to the libref to get a listing of all files in the library. Add the NODS option to suppress detailed information about the files. As an alternative to PROC CONTENTS, you can use PROC DATASETS.

Specifying Result 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 that is created during your SAS session. To open this window, select Tools

Specifying Result Formats
Options
Specifying Result Formats
Preferences
. Then click the Results tab. Choose Create listing, Create HTML, or both.

If you choose Create HTML, then 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 to 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 the 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 until you 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.

To specify the observations to process from SAS data sets, you can use the FIRSTOBS= and OBS= options.

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

Additional Features

You can set a number of additional SAS system options that are commonly used.

Syntax

LIBNAMElibref 'SAS-data-library';

LIBNAME libref engine 'SAS-data-library';

OPTIONS options;

PROC CONTENTS DATA= libref._ALL_ NODS;

PROC DATASETS;

        CONTENTS DATA= libref._ALL_ NODS;

QUIT;

Sample Program

options pagesize=54 linesize=76 pageno=10
        yearcutoff=1925;
libname acctqtr3 'd:usersqtr
eports';
proc contents data=acctqtr3._all_ nods;
run;
proc datasets;
   contents data=acctqtr3._all_ nods;
quit;
options firstobs=50;
proc print data=acctqtr3.sales(obs=100);
run;
libname rptdata spss 'g:patients
eports.dat';
proc print data=rptdata.new_tests(firstobs=100 obs=500);
run;

Points to Remember

  • LIBNAME and OPTIONS statements remain in effect for the current SAS session only.

  • When you use SAS windows to specify librefs or system options, you cannot store the specifications in your SAS programs as you can when you use 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.

Chapter Quiz

Select the best answer for each question. After completing the quiz, check your answers using the answer key in the appendix.

  1. If you submit the following program, how does the output look?

    options pagesize=55 nonumber;
    proc tabulate data=clinic.admit;
       class actlevel;
       var age height weight;
       table actlevel,(age height weight)*mean;
    run;
    options linesize=80;
    proc means data=clinic.heart min max maxdec=1;
       var arterial heart cardiac urinary;
       class survive sex;
    run;
    1. The PROC MEANS output has a print line width of 80 characters, but the PROC TABULATE output has no print line width.

    2. The PROC TABULATE output has no page numbers, but the PROC MEANS output has page numbers.

    3. Each page of output from both PROC steps is 55 lines long and has no page numbers, and the PROC MEANS output has a print line width of 80 characters.

    4. The date does not appear on output from either PROC step.

  2. How can you create SAS output in HTML format on any SAS platform?

    1. by specifying system options

    2. by using programming statements

    3. by using SAS windows to specify the result format

    4. you can't create HTML output on all SAS platforms

  3. In order for the date values 05May1955 and 04Mar2046 to be read correctly, what value must the YEARCUTOFF= option have?

    1. a value between 1947 and 1954, inclusive

    2. 1955 or higher

    3. 1946 or higher

    4. any value

  4. When you specify an engine for a library, you are always specifying

    1. the file format for files that are stored in the library.

    2. the version of SAS that you are using.

    3. access to other software vendors' files.

    4. instructions for creating temporary SAS files.

  5. Which statement prints a summary of all the files stored in the library named Area51?

    1. proc contents data=area51._all_ nods;
    2. proc contents data=area51 _all_ nods;
    3. proc contents data=area51 _all_ noobs;
    4. proc contents data=area51 _all_.nods;
  6. The following PROC PRINT output was created immediately after PROC TABULATE output. Which system options were specified when the report was created?

    Chapter Quiz
    1. OBS=, DATE, and NONUMBER

    2. NUMBER, PAGENO=1, and DATE

    3. NUMBER and DATE only

    4. none of the above

  7. Which of the following programs correctly references a SAS data set named SalesAnalysis that is stored in a permanent SAS library?

    1. data saleslibrary.salesanalysis;
          set mydata.quarter1sales;
          if sales>100000;
      run;
    2. data mysales.totals;
          set sales_99.salesanalysis;
          if totalsales>50000;
      run;
    3. proc print data=salesanalysis.quarter1;
          var sales salesrep month;
      run;
    4. proc freq data=1999data.salesanalysis;
          tables quarter*sales;
      run;
  8. Which time span is used to interpret two-digit year values if the YEARCUTOFF= option is set to 1950?

    1. 1950-2049

    2. 1950-2050

    3. 1949-2050

    4. 1950-2000

  9. Assuming you are using SAS code and not special SAS windows, which one of the following statements is false?

    1. LIBNAME statements can be stored with a SAS program to reference the SAS library automatically when you submit the program.

    2. When you delete a libref, SAS no longer has access to the files in the library. However, the contents of the library still exist on your operating system.

    3. Librefs can last from one SAS session to another.

    4. You can access files that were created with other vendors' software by submitting a LIBNAME statement

  10. What does the following statement do?

    libname osiris spss 'c:myfilessasdatadata';
    1. defines a library called Spss using the OSIRIS engine

    2. defines a library called Osiris using the SPSS engine

    3. defines two libraries called Osiris and Spss using the default engine

    4. defines the default library using the OSIRIS and SPSS engines

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset