Getting Your Data into SAS
Statistical Data Analysis 1
Namhyoung Kim
Dept. of Applied Statistics Gachon University
nhkim@gachon.ac.kr
1
Structure of SAS data set
ID NAME GENDER WEIGHT HEIGHT
1 101 김철수 M 74 170
2 102 이영희 F 68 166
3 103 안수지 F 55 155
4 104 박민호 M 72 167
5 105 M 66 169
6 106 강지영 F 52
observations(rows) missing value
variable (columns)
Data types
numeric: numbers
character: everything else. may contain numerals, letters, or special characters can be up to 32,767 characters long.
(cf. ZIP codes)
Methods for Getting Your Data into SAS
creating SAS data sets from raw data files
the DATA step
the Import Wizard
entering data directly into SAS data sets
the Viewtable window
SAS Enterprise Guide software
3
Creating SAS data sets from raw data files
Raw data
Variable
name contents Colum
n No. Code values
id 고객번호 1-2 고유번호(ID)
age 연령대 3
1=20대, 2=30대, 3=40대, 4=50대, 5=60대 이상
gender 성별 4 M=남자, F=여자
item1 좋은 제품을 만들기 위해 노력한다 5
1=예, 2=보통, 3=
아니오, .=모름/무응 답
item2 소비자를 중요하게 여긴다 6
item3 신뢰할만한 기업이다 7
text file: 기업이미지.txt code book
Creating SAS data sets from raw data files
5
DATA name ; INFILE ‘path and filename’;
INPUT variable_name ($) col_no;
Creating SAS data sets from raw data files
results
Using imported data in a SAS program
7
or, since WORK is the default library, you could also use:
Using imported data in a SAS program
results
SAS Data Libraries
SAS library
a location where SAS data sets(as well as other types of SAS files) are stored.
a folder or directory on your computer, or a physical location like a hard drive, USB or CD.
WORK library: a temporary storage location(default)
SASHELP, SASUSER libraries
To set up a library
using the LIBNAME statement
using the New Library window in the SAS Windowing Environment
9
Using permanent SAS Data Sets with LIBNAME statements
LIBNAME library ‘folder’
Using permanent SAS Data Sets with Library explorer
11