Cover Image
close this bookStrengthening Policy Analysis - Econometric tests using microcomputer software + disk (IFPRI, 1995, 166 p.)
View the document(introduction...)
View the documentPreface
View the documentAcknowledgments
View the document1. Introduction
View the document2. Software Information
View the document3. Data Handling
View the document4. Specification Tests
View the document5. Deficient Data Problems
View the documentAppendix 1:SPSS/PC+ Environment and Commands
View the documentAppendix 2: SAS PC Environment and Commands
View the documentAppendix 3: Gauss-386 Environment and Commands
View the documentBibliography

Appendix 2: SAS PC Environment and Commands

ENVIRONMENT

· Starting a SAS PC Interactive Session

To start a SAS PC interactive session, from the DOS prompt, type SAS.

· Ending an Interactive Session

To end an interactive session, type BYE or END from any ===> command line.

· Screen Panels or Windows

The three screen panels or windows are as follows:

PROGRAM EDITOR

From here, you can submit and edit commands interactively or in batches.

LOG

This is a record of all SAS PC commands issued in the session; you should save this at the end of the session.

OUTPUT

This is a record of all results generated in the session; you should save this at the end of the session.

· Moving Between Windows

To move between windows, use the function keys. Press

F3 to move to the LOG window,
F4 to move to the OUTPUT window, and
F5 to move back to the PROGRAM EDITOR window.

· Entering a Command Interactively

To enter a command interactively, move from the ===>command line to line 1 of the editor, type in your command, and then submit your command by pressing F10. Groups of commands can also be submitted in this way.

· Recalling a Group of Commands from the Memory Buffer

To recall a group of commands from the memory buffer, press F9.

· Returning to the Command Line

To return to the command line, ===>, press HOME

· Clearing a Window

To clear a window, type CLEAR at the window’s ===> prompt.

· Expanding a Window

To expand the window you are working in, type ZOOM at the ===> command line.

· The Program Editor

You may edit commands by altering the 00000 lines on the left of the screen, as follows:

00d000

Deletes that line and renumbers the lines. (The d can be in any position.)

0dd000 to 0dd000

Deletes the blocked-off lines.

00ib00

Inserts a blank line before the current line.

00ia00

Inserts a blank line after the current line.

0cc000 to 0cc000

Blocks lines for copying.

A complete list of line commands is available on pages 339-340 of the SAS Language Guide for Personal Computers (SAS Institute, Inc. 1988).

NOTE: You can use SAS PC perfectly well without being very proficient with this editor by editing program command files with WordPerfect (saving as text), or NORTON EDITOR, and then submitting as batch files (see Editing Input (Command) and Output (Log and Results) Files, below).

· Editing Input (Command) and Output (Log and Results) Files

Files containing SAS PC commands can be brought into the PROGRAM EDITOR window with the INCLUDE command by typing the following at the ===> prompt:

INCLUDE ‘filename.SAS’

The command file can be created with any word processor/editor. After bringing the file into the program editor with INCLUDE, it can be submitted by pressing F10.

· Saving Output or Log Windows

To save output in the output or log windows, type the following at the ===> prompt of the output or log windows:

FILE ‘fiIename.out’

· Submitting a SAS PC Command File from DOS

Either of the following statements will execute the SAS PC commands in the file filename.SAS:

d:subdir> SAS filename

or

d:subdir> SAS filename.SAS

In addition, SAS PC will create a filename.LOG file and a filename.LST file for you.

· DOS Interface

DOS commands can be run from within SAS PC by typing X at the ===> prompt. For example, the following will execute the DOS command without directly entering the DOS shell:

X ‘dos command/’

Typing only X at the ===> prompt puts you into DOS. Typing EXIT at the DOS prompt will put you back in SAS PC.

· Interrupting a Sequence of Commands

To interrupt a sequence of commands, press CTRL+BREAK and you will be asked if you want any of the submitted commands to be terminated. There is a default NOREPLACE option that does not allow a system file overwrite if there is a syntax error in the program, or if you terminate with CTRL+BREAK. However, whenever the program runs and you have the same name on the DATA and SET lines, your SAS PC data set will be automatically overwritten.

· SAS PC COMMANDS

SAS PC commands fall into three categories (see inside cover of SAS Language Guide for Personal Computers [SAS Institute, Inc. 1988]): statements used in DATA steps, statements used in PROC steps, and statements used anywhere. Nearly all of the SAS PC commands in the following sections must be issued from the 0000n lines in the PROGRAM EDITOR (or from a command file), but not the ===> line.

· The DATA Step

Most operations that alter or create a SAS PC data set (similar to an SPSS/PC+ system file) are carried out within a DATA step. Examples: merging, creating new variables, and selecting subsamples.

DATA;

SAS statements

RUN;

· The PROC Commands

Most SAS PC data transformation procedures and all statistical procedures are carried out with PROC commands, for example, REGRESSION, FREQUENCIES, and MEANS. SAS PC procedures often include options such as BY, CLASS, WEIGHT, and others.

PROC procedure;

SAS statements

RUN;

· The RUN Statement

A SAS PC command, or set of SAS PC commands, will be executed when followed by

RUN;

· Labeling DOS Subdirectories: The LIBNAME Command

The statement

LIBNAME label ‘D:subdir’ ;

tells SAS PC that, for the rest of the session, label points to the subdirectory D:subdir. For example,

LIBNAME elast ‘D:calinc’;

labels the CALINC subdirectory on the D drive as ELAST. Note that up to eight characters can be used to label the subdirectory.

· SAS PC Data Set Name Conventions

There are two types of SAS PC data sets: permanent and temporary. The SAS internal and DOS names of these data sets are as follows:


Permanent

Temporary

SAS internal name

label. filename

filename

DOS internal name

D:subdirfilename.SSD

C:SASSASWORKfilename.SSD

For example, the set of commands

LIBNAME elast ‘D:calinc’;
DATA elast.hhcal;

sascommands

RUN;

labels the CALINC subdirectory as ELAST, and constructs a permanent SAS PC data set ELAST.HHCAL, which, after the SAS PC session has ended, will be found in the CALINC subdirectory as HHCAL.SSD.

The set of commands

DATA hhcal;

sascommands

RUN;

will construct a temporary SAS PC data set, HHCAL, which will temporarily reside in C:SASSASWORK as HHCAL.SSD, but will be deleted automatically when the session ends.

· Constructing a SAS PC Data Set from a Text (ASCII) File

To construct a SAS PC data set from a text (ASCII) file, use the INPUT command:

DATA irrig1;

INFILE ‘c:DATAMANUAL.ASC’ ;
INPUT v1 v2 v3 v4 v5;

RUN;

The five variables in text file WATER.DAT (and named by the user as v1 to v5) will be read into a temporary SAS PC data set called IRRIG1.

· Constructing a SAS PC Data Set from Another SAS PC Data Set

To construct a SAS PC data set from another SAS PC data set, use the SET command:

LIBNAME water ‘D:ghana’;

DATA water.irrig3;
SET water.irrig2;
sascommands

RUN;

This example brings in the permanent SAS PC data set WATER.IRRIG2 - located in subdirectory D:GHANA, which is labeled as WATER (using LIBNAME) - to serve as the starting point for the creation of a new permanent SAS PC data file. The new permanent file is called WATER.IRRIG3 and is located in D:GHANA as IRRIG3.SSD.

· Writing to ASCII

To write to ASCII, use the PUT and FILE commands:

DATA instrum;

SET elast.jh1508;
FILE ‘instrum.dat’;
PUT v1 v2 v3 v4 v5;

RUN;

This example will construct a temporary SAS PC data file, INSTRUM, for the purpose of writing variables v1 to v5 from the permanent SAS PC data set, ELAST.JH1508, to a text file, INSTRUM.DAT.

· Customizing the Work Environment

The OPTIONS command is a stand-alone command used to customize the whole work environment. This command can appear anywhere outside of a DATA step. The following example sets output page length to 66 lines.

OPTIONS PAGESIZE=66;

· Inserting Comments in the Program

To insert comments, use the following format:

* comment;

SAS PC comment lines can appear anywhere outside of a DATA step.

· The AUTOEXEC.SAS File

This text file resides in C:SAS and is similar to the AUTOEXEC.BAT file in C: in that it allows you to execute some of the commands every time you enter SAS PC. For example, you may find it convenient for your AUTOEXEC.SAS file to include your most common LIBNAME commands; in this way, you do not have to enter them at each session.