getting your data into sas 2 - kocwcontents.kocw.net/kocw/document/2014/gacheon/kimnamh... · 2016....

27
Getting Your Data into SAS_2 Statistical Data Analysis 1 Namhyoung Kim Dept. of Applied Statistics Gachon University [email protected] 1

Upload: others

Post on 05-Mar-2021

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Getting Your Data into SAS_2

Statistical Data Analysis 1

Namhyoung Kim

Dept. of Applied Statistics

Gachon University

[email protected]

1

Page 2: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

SAS library and Viewtable

2

Page 3: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Reading a permanent SAS data set

DATA=library.data_set_name; Proc Step

Data Step

3

Page 4: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Reading files with the Import Wizard

4

Page 5: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Reading files with the Import Wizard

5

Page 6: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Reading files with the Import Wizard

6

Page 7: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Reading files with the Import Wizard

7

Page 8: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Reading files with the Import Wizard

8

Page 9: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Using IMPORT procedure

PROC IMPORT DBMS=EXCELDATAFILE="D:\SAS_Programming\Raw_Data\기업이미

지.xls"OUT=mysas.company

REPLACE;

RANGE="Sheet1$";

RUN;

PROC IMPORT DBMS=SPSSDATAFILE="D:\SAS_Programming\Raw_Data\기업이미

지.sav"OUT=mysas.company

REPLACE;

FMTLIB=mysas.company_formats;

RUN;

9

Page 10: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Internal Raw Data

CARDS statements

10

Page 11: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Entering Data with the ViewtableWindow

11

Page 12: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Practice

Drink 데이터셋을 생성하기 위하여 다음을 수행하여 보아라 텍스트파일 ‘음료수.txt’를 이용하여 mysas.drink 데이

터셋을 생성하여라 Excel 파일 ‘음료수.xls’를 이용하여 mysas.drink 데이

터셋을 생성하여라 SPSS 파일 ‘음료수.sav'를 이용하여 mysas.drink 데

이터셋을 생성하여라

12

Page 13: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Practice

아래 자료를 텍스트 파일로 저장하고, 이 텍스트파일을 INFILE 명령문을 이용하여 SAS 데이터셋으로 저장하여라

13

1 Monona Steve 322 Milwaukee Tom 443 Madison Kim 25

변수 내용 열 번호

Obs 고객 번호 1-2

City 도시 3-12

Name 성명 13-18

Age 나이 19-20

<텍스트 자료> <코드북>

Page 14: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

SAS library and Viewtable

14

Page 15: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Reading a permanent SAS data set

DATA=library.data_set_name; Proc Step

Data Step

15

Page 16: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Reading files with the Import Wizard

16

Page 17: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Reading files with the Import Wizard

17

Page 18: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Reading files with the Import Wizard

18

Page 19: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Reading files with the Import Wizard

19

Page 20: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Reading files with the Import Wizard

20

Page 21: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Using IMPORT procedure

PROC IMPORT DBMS=EXCELDATAFILE="D:\SAS_Programming\Raw_Data\기업이미

지.xls"OUT=mysas.company

REPLACE;

RANGE="Sheet1$";

RUN;

PROC IMPORT DBMS=SPSSDATAFILE="D:\SAS_Programming\Raw_Data\기업이미

지.sav"OUT=mysas.company

REPLACE;

FMTLIB=mysas.company_formats;

RUN;

21

Page 22: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Internal Raw Data

CARDS statements

22

Page 23: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Entering Data with the ViewtableWindow

23

Page 24: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Practice

Drink 데이터셋을 생성하기 위하여 다음을 수행하여 보아라 텍스트파일 ‘음료수.txt’를 이용하여 mysas.drink 데이

터셋을 생성하여라 Excel 파일 ‘음료수.xls’를 이용하여 mysas.drink 데이

터셋을 생성하여라 SPSS 파일 ‘음료수.sav'를 이용하여 mysas.drink 데

이터셋을 생성하여라

24

Page 25: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Practice

아래 자료를 텍스트 파일로 저장하고, 이 텍스트파일을 INFILE 명령문을 이용하여 SAS 데이터셋으로 저장하여라

25

1 Monona Steve 322 Milwaukee Tom 443 Madison Kim 25

변수 내용 열 번호

Obs 고객 번호 1-2

City 도시 3-12

Name 성명 13-18

Age 나이 19-20

<텍스트 자료> <코드북>

Page 26: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Practice

‘C:\’ 에 example 폴더를 생성하고 이 폴더를 ‘ex’라는 이름의 SAS 라이브러리로 생성하여라. 생성한 ‘ex’ 라이브러리에 문제 2-6번의 데이터를저장하여 보아라.

26

Page 27: Getting Your Data into SAS 2 - KOCWcontents.kocw.net/KOCW/document/2014/gacheon/kimnamh... · 2016. 9. 9. · Practice 아래자료를텍스트파일로저장하고, 이텍스트

Practice

아래의 데이터셋을 엑셀 파일로 저장하고IMPORT 프로시저와 데이터 가져오기 마법사를각각 이용하여 저장한 엑셀 파일을 SAS 데이터셋으로 변환하여라.

27

Region State Month Expenses Revenue

Southern GA JAN2001 2000 8000

Southern GA FEB2001 1200 6000

Southern FL FEB2001 8500 11000

Northern NY FEB2001 3000 4000

Northern NY MAR2001 6000 5000

Southern FL MAR2001 9800 13500

Northern MA MAR2001 1500 1000