Personal tools
Section Navigation > Home > Answers > Reference Manuals > Guide to Using SAS for Windows > Features and Utilities
Navigation
Antivirus Software

McAfee Image

Download security software

Free for all university
students, faculty, and staff
personally owned computers

ASU Webmail

Email for 2008-2009 Freshmen
and new student accounts


ASU Webmail
Powered by Google


FAQ

Log in
Sign in to support to access additional resources for faculty, staff, and students.

Change Text Size

A      A      A

 
Document Actions

5. Features and Utilities

 
Up one level
Descriptions of some program windows, utilities, and useful methods used in SAS.

Explorer Window

The Explorer Window gives you easy access to SAS files and libraries. You can create new Libraries, Files or File Shortcuts. If you plan to access an existing SAS data set, or create a new one, it is important to define a “libref” for the folder or subdirectory that contains, or will contain the SAS data set. The term “libref” is short for SAS library reference, and it can be thought of as a nickname or arrow pointing to a particular folder or subdirectory on your system. To create a libref, make sure the Explorer Window is the active window and then click on the New Library icon in the toolbar, or click on File > New > Library. In the New Library window, enter a name for the libref (8 characters maximum, must begin with a letter, and can not contain spaces) and an Engine (use Default or V9). “Engine” simply refers to the access method, or set of internal instructions SAS will use in reading or writing files in the specified folder. Finally, in the Path window, specify the subdirectory or folder where you want to save the new SAS data set and click OK.

Viewtable Window

The Viewtable window can be used to create, view, or edit a SAS data set. Two views are possible, "Table View", consisting of rows and columns, and "Form View", which displays only one observation at a time. In Form View you can use the default data layout or create a customized design to meet special needs.

To initiate Viewtable to create a new file, click Tools > Table Editor. The initial Viewtable window displays rows, which represent observations and are labeled with numbers, and columns, which represent variables and are labeled with letters. You can click on the letter at the top of each column to enter a title, and you can type data directly into the grid, but it is usually better to define the column or variable attributes before entering data. Click on Data and Column Attributes. If necessary, move the Column Attribute window so that the row of column letters is visible, and click on the first column letter. In the Column Attribute window enter a name for the column, a label, format and data type. Variable or column names can be up to 32 characters long, must begin with a letter and can contain letters, digits or the underscore, but they can not contain any spaces. Click on each column that will be needed for the data set, enter that column's name and attributes, and when complete, close the Column Attribute window and begin entering data. When entering data press the tab key to move across each row, or press the Enter key followed by an arrow key (either across or down) to move the cursor to the next data cell. To save the data as a SAS system data file, click File > Save or Save As. In the “Save As” window, click on the library (subdirectory) where the file is to be saved and type in a “Member Name”, ie. filename for the saved data set. The filename should not contain any spaces. The filename extension will be “.sas7bdat”.

You can also browse or edit an existing SAS data set in the Viewtable window. Click on the Explorer window to make it the active window, and browse to the libref containing the desired file. Double click on the filename to open the file in the Viewtable window. Alternately, you can click on Tools > Table Editor to open the Viewtable window first, and then click on File > Open. The left hand side of the Open dialog box will list the libraries or librefs currently identified in your SAS session. Select the library and SAS data set that you wish to view. The file is opened in Browse mode, but you can switch to Edit mode by clicking on Edit > Edit Mode. Be sure to specify Row Level Edit Access or Table Level Edit Access. You can edit individual cells, add, delete or copy rows, or sort the data. You can not add a new column. To add a row or rows, click on Edit > Add Row or click on the Add Row icon, and add the data for the new row. To continue adding new rows of data, click the Add Row icon again. When all the new data has been entered, click on the Commit New Row icon. NOTE: it is important to remember that when you enter new data it is saved immediately and automatically in the file. If you change your mind on any of the additional data items, you must go back and delete the item or items.

Converting SAS Version 8 Data Sets and Catalog files to Version 9

SAS version 8 data files (*.sas7bdat file extension) can be read and updated by SAS 9.1.3 directly, without doing any conversion. If you simply read your version 8 data set into a SAS 9.1.3 session and save it, it will be saved as a version 9 file. However, SAS version 8 catalog files (*.sas7bcat file extension) require the use of Proc Migrate to convert them to version 9. Use a program similar to the following:

    /* SAS program to convert version 8 catalog files to version 9 */
    libname source v8 ‘folder location of v8 catalogs, ie. c:\v8catalogs';
    libname target v9 ‘folder location of v9 files, ie. c:\v9catalogs';
    proc migrate
       in=source out=target;
    run;

Import Wizard

The SAS Import Wizard can be used to read data sets in a variety of formats: Microsoft Access, Excel, dBase, Lotus, comma separated value (*.csv), other delimited files, or a file in a user defined format. Before using the Import Wizard, you should set up a libref for the folder where you want to save the new SAS file. If you skip this step then the new SAS file can be saved in the default SASUSER folder:
   C:\Documents and Settings\ username \My Documents\My SAS Files\9.1
Refer to the section above, Explorer Window, for details on creating a libref.

To import a Microsoft Excel file: in the main menu, click File and Import Data to open the Import Wizard. There are two initial choices, "Standard data source" or "User defined file format". Click the “Standard data source” box, and in the “Select a data source from the list below” window, be sure that “Microsoft Excel 97, 2000, or 2002 Workbook” is selected. Click Next and in the “Connect to MS Excel” window, browse to the location of the Excel file and click OK. The Options button allows you to specify a specific Worksheet/Range, to state whether or not the first row contains variable names, and to specify how to handle date variables. Note: only one worksheet can be imported at a time. Next you will need to specify a destination for the SAS file, a libref (Library name) and a data set name (Member name). After entering this information, you can lick Finish to complete the import process or Next to get the option of saving the Proc Import statements. After clicking on Finish, the Log window will contain a message stating that the SAS data set has been successfully created, or error messages if the process was not successful. Once the SAS file has been created you can view it in a Viewtable window or refer to it in a Data or Proc step.

A Microsoft Access file can also be imported and saved as a SAS data set. The procedure is essentially the same as that used for an Excel file, except that in the “Select import type” window, specify “Microsoft Access 2000 or 2002 Database”.

 

© 2007 Appalachian State University Boone, NC 28608 / 828-262-2000