Introduction to SAS - PowerPoint PPT Presentation

1 / 38
About This Presentation
Title:

Introduction to SAS

Description:

Logging in to the SIL. Turn on computer. Enter your user name ... Choose Window Tile Horizontally. Type code. Submitted code. ERRORs, WARNINGs, benign feedback ... – PowerPoint PPT presentation

Number of Views:77
Avg rating:3.0/5.0
Slides: 39
Provided by: vonhi
Category:

less

Transcript and Presenter's Notes

Title: Introduction to SAS


1
Introduction to SAS
Paul von Hippel Department of Sociology Ohio
State University October 22, 2004
2
Topics
  • Getting started
  • Getting data in
  • Manipulating data
  • Graphics
  • Analysis
  • Getting results out
  • Reducing repeated code

3
I. Getting Started
  • Logging in
  • Opening SAS
  • SAS windows

4
Logging in to the SIL
  • Turn on computer
  • Enter your user name
  • If your OSU email is buendia.100_at_osu.edu
  • then your SIL user name is buendia.100
  • not the same as in SRL
  • Enter your password
  • your first initial last 4 digits of your SS
    your last initial
  • e.g., Jose Arcadio Buendia, SS 100-10-0100
  • password j0100b
  • again not the same as in SRL

5
Opening SAS (in the SIL)
  • Lower left corner, click Start
  • Choose
  • Programs
  • Analysis
  • SAS V8

6
SAS windows
  • Choose Window?Tile Horizontally

Type code
Submitted code ERRORs, WARNINGs, benign feedback
See output
7
Saving code
  • Name the contents of the Editor window
  • currently blank
  • Select the editor window
  • Choose File?Save as
  • X\brownbag.sas
  • Save regularly

8
II. Getting data in
  • The DATA step
  • - with DATALINES
  • - with INFILE
  • The IMPORT procedure

9
DATA step with DATALINES
Type in Editor window
10
(A word on DATA steps)
Basic structure DATA datasetname RUN
Each statement ends with a semicolon INPUT
describes the format character variables
followed by DATALINES introduces the data. /
comments enclosed /
11
Submitting code
Highlight and submit code
12
Viewing dataThe PRINT procedure
13
(A word on PROCEDURES)
Basic structure PROC procedure
DATAdataset RUN Each statement ends
with a semicolon E.g., PROC print
DATAMissAmericas RUN
14
DATA step with DATALINES
If you have a lot of lines, typing DATALINES is
inconvenient.
15
DATA step with INFILE
16
The IMPORT procedure
If there are a lot of variables in different
formats, the INPUT statement can be cumbersome
IMPORT figures out the variable types (numeric,
character, etc.) and takes variable names (Year,
Name, etc.) from the first row.
17
Where is the data?
  • Data file Missamericas
  • Library Work (default)
  • Work is a temporary folder on some disk
  • erased when you quit SAS

18
Making a permanent SAS data set
MYLIB points to X\. You could also say
X\somefolder\ or. MYLIB.missamericas is a
file on X\ If no library were specified, WORK
(temp disk space) would be assumed. Can you find
mylib and missamericas in the SAS Explorer? Can
you find missamericas.sas7bdat on the X drive?
19
Retrieving a permanent SAS data set
  • Quit SAS and relaunch it
  • See? The contents of mylib are permanent.

20
III. Manipulating data
21
The DATA step with SET
Define some new variables
22
IV. Graphics
23
PROC GPLOT
24
The UNIVARIATE commandwith the HISTOGRAM
statement
25
V. Analysis
26
The REG procedure
27
VI. Getting results out
  • The Output window
  • The Output Delivery System
  • The EXPORT procedure

28
Save the output window
  • Click in the output window
  • Choose File?Save As

29
Save selected results with ODS
  • Every part of the output has a name
  • If you know the name
  • you can save that part of the output
  • as a data file
  • To do this, use the Output Delivery System (ODS)

30
Whats the outputs name?
31
Saving the output
  • int_slope is a data set
  • Can you find it?

32
Doctoring the output
33
The EXPORT procedure
  • Results.xls is an Excel file.
  • Can you find it?

34
VII. Reducing repeated code
  • Macros

35
Macros
  • Often you need to repeat analyses
  • with minor adjustments
  • Instead of cutting and pasting
  • use a macro

36
Macros
  • Basic structure
  • macro choose_a_name (arg1, arg2)
  • / SAS code using arg1, arg2 /
  • mend

37
Macros
  • Dont say
  • Instead, say

38
To learn more
  • Online documentation
  • wks.uts.ohio-state.edu/sasdoc/8/sashtml/onldoc.htm
  • very technical
  • The Little SAS Book
  • in SRL, great introduction reference
Write a Comment
User Comments (0)
About PowerShow.com