SAS Software Introduction



SAS Software Introduction Ron Briggs UTD 12/99

1. SAS

--10th largest software company in world

--used by more organizations than any software product except for standard PC packages

--works in multiple different computing environments (Windows, MAC, IBM mainframe)

--similar interface on each

--same program will run on each

--it is a programming environment & language for data manipulation & analysis

--multiple modules available for different types of analysis

SAS/STAT for statistical analysis

SAS/ETS for econometric time series

SAS/GIS for GIS

SAS/OR for operations research/logistics

2. When and Why?

--for data preparation when Excel runs out of steam: e.g when:

--input data is not row by column

--needs complex rearrangement

--too many observations and/or variables

--batch and repetitive data processing as well as “one-off” analyses

--VB is primarily for application development

--for sophisticated statistical and other analyses (e,g. OR)

--other stat packages (e.g. SPSS, SYSTAT, STATA) only do stat.

3. Loading SAS in Green Lab

--Use desktop icon to ensure correct load

4. SAS Interface (Version 7)

Explorer

--like Windows and Internet Explorer

--provides access to files;

Libraries for SAS data sets

Short cuts to access non-SAS data sets

Program Editor

--enter and edit SAS programs

Log Window

--displays messages about your SAS session

--lists programs you submit and tells you how they ran

Output

--outputs (results) from SAS programs you run

--traditionally, this was “printout”

--positioned behind Program Editor/Log Window

--moves to foreground after a program submitted

Results

--used to manage outputs from programs

--positioned behind Explorer window

--moves to foreground after a program submitted

Note that buttons along the bottom of the windows allow you to flip between these different windows.You can also use Window pull-down menu for this.

5. Accessing File Information

--double click Libraries in Explorer window to see list of libraries

--double click a library (e.g.) sashelp to see library contents

--use Up-one-Level tool (1st tool) to move back

--click Tree tool (11th tool) to get a “tree” view (I prefer this)

--double click any entry with a “table icon” (e,g citimon) and VIEWTABLE window opens

--this shows you the data in the table

--close with X icon in upper right

--right click any entry with a “table icon” and select Properties

--this gives you information about table contents

--be sure to notice the options box at top

--there are multiple sets of info available

--double click File Shortcuts

--nothing shows! (‘cos no short cuts defined yet)

--Select File/New pull down menu

New File Shortcut Window opens

Click Browse and go to: p:\briggs\poec5317 \

In Files of Type window, select Data Files (.dat)

Select STATE.DAT and click Open

In New File Shortcut Name enter: USst80

You now have a shortcut to this file

--for general viewing of all folders and files

--select View/My Favorite Folders pull down menu

--you can also create shortcuts here

--select a file

--right click, and select Create File Short Cut

6. Creating and Naming Your Own SAS Libraries

In SAS you make extensive use of SAS data sets (tables) saved as files

These are organized into Libraries (altho these are not physical folders)

--go to My Computer (or Windows Explorer) and create a folder called:

c:\usr\ron\sas5317

--make SAS Explorer window active

--To create a new Library, select File/New pull down menu

--click Library, click OK. New Library Window opens. Specify:

Name: Popdata

Engine: Default

Enable at Startup: CHECK ON

Path: c:\usr\ron\sas5317\ (be sure this entire name shows in Path window)

Click OK

--To copy into a library, use drag and drop, for example

--make SAS Explorer active in Tree style (use View/Show Tree if necessary)

--single click Sashelp library

--drag any “table icon” into Popdata

--single click Ustates: dragged file name should appear on right side

--right click on file, and select Rename to rename the file to JUNK

--To see how SAS names Libraries and Folders,

--Select View/My Favorite Folders

--navigate to folder where file saved (e.g. c:\usr\ron)

--there will be a file called: junk.sas7bdat

--the extension of sas7bdat tells the engine or format used

--the library name (popdata in SAS Explorer) is a nickname or alias pointing to the folder where the sas data set is saved (c:\usr\ron\sas5317)

--the folder can contain other files, although this is not wise

--it cannot contain sas data sets written with a different “engine”

7. Importing Non-SAS Files into SAS

Standard non-SAS data sets such as .dbf files, Excel spreadsheets (.xls) and delimited files can be brought into SAS using the SAS Import Wizard

--select File/Import Data

--select Standard Data Source (default) option

--for type of data set specify Excel 97, and click Next

--select the file: p:\briggs\poec5317\stpop97.xls,

click options button and select Worksheet Range data97, click OK then Next

(always use a named data range in Excel, to avoid extra ‘junk’ in SAS data set)

--select Library: usstate Member: stpop97, and click Next

--specify file name (with extension of .sas) to save import program code (if desired):

c:\usr\ron\sas5317\stpop97.sas, and click Finish

--messages from this operation appear in the Log window, namely

NOTE: USSTATE.STPOP97 was successfully created.

--this wizard created SAS program code which was saved in the file

c:\usr\ron\sas5317\stpop97.sas

--this code read the Excel file, converted it to a SAS data set, and saved as a new file called

c:\usr\ron\sas5317\stpop97.sas7bdat

--note: disk file is called stpop97.sas7bdat but internal to SAS it is USTATE.STPOP97

To import more complex data sets use the User-defined file format option (EFI--external file import).

8. Using the Program Editor Window: View, Save and Clear SAS code

The Program Editor window is used to view and edit SAS program code, and submit it for processing

--to view existing sas code

--be sure Program Editor is the active window (title bar is blue)

--select File/Open and specify location of a file containing sas code

--file should have an extension of .sas (not required, but may cause problems if not)

--for example, to view code from import wizard: c:\usr\ron\sas5317\stpop97.sas

--to save code in this window as a file, use File/Save (and be sure to use an extension of .sas)

--to clear this window of all code, use Edit/Clear All

--be sure you save it first!

--clearing this window does not delete any saved files

9. Using the Program Editor Window: Running SAS Programs

SAS program code is submitted from the Program Editor Window.

--obtain existing SAS code: use File/Open and select p:\briggs\poec5317\sasex1.sas

--submit this SAS code: use Run/Submit (or click “Running Person” icon)

--results of analyses are shown in the Output window

--these may be saved or printed using File/Save or File/Print

--the window may be cleared by using Edit/Clear All (but don’t do this yet)

--the Log window which tracked the code as it ran may be viewed by: Window/Log

--code submitted ( that is, lines from Program Editor) are displayed in black

--messages are displayed in blue

--the Program Editor window can be viewed by: Window/Program Editor

--it will be empty! You can recall the code you just ran by: Run/Recall Last Submit

--recalled code may be re-run by again selecting Run/Submit

--before running (or re-running), it is often wise to clear the Output and Log windows

--make the window active and select: Edit/Clear All

10. SAS/Assist

An interface for running SAS procedures without writing SAS code.

Access via Solutions/Assist

--a new window called SAS/ASSIST Workplace opens

--this is the access point to SAS ASSIST

--it lists the various tasks available in SAS/ASSIST

--these same tasks are available via the Tasks pull down menu

If you have run this before, another menu will appear first:

--be sure Workplace is checked, and click Continue

--the other option, Block Menu, is for consistency with earlier versions of SAS

11. Using the External File Import (EFI) option in File/Import

More complex data sets can be brought into SAS using the External File Import

--select File/Import Data

--click button next to User-defined file format

(note: a depressed button indicates selection)

See Help/Index and go to topic: Import for details on use

If file is too complex to be handled by this wizard, then you will need to write code directly.

12. Programming in SAS

See the powerpoint presentation sas.ppt available at:

utdallas.edu/briggs/poec5317.html

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download

To fulfill the demand for quickly locating and searching documents.

It is intelligent file search solution for home and business.

Literature Lottery

Related searches