자료의 결합(sas 프로그램)
본 자료는 5페이지 의 미리보기를 제공합니다. 이미지를 클릭하여 주세요.
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
해당 자료는 5페이지 까지만 미리보기를 제공합니다.
5페이지 이후부터 다운로드 후 확인할 수 있습니다.

목차

Lecture 06

자료다루기

자료간의 연결관계 (Data Relationship)

자료의 결합(combining multiple data sets )

결합방법 (6가지 method)
세로결합
1. 상하 자료결합(Concatenating) (SET, PROC APPEND, SQL)
2. 세로 끼워 넣기 (interleaving)
3. SET 문에 의한 가로 결합 (One-to-one reading)
4. MERGE 문에 의한 자료결합 ---> 가로 결합에 변수를 추가하는 경우
4.2 Match Merging (MERGE 문에 의한 대응가로결합)

본문내용

0 0 2 0 0 0 1.000
양준혁 2003.04.24 기아 4 4 0 0 0 0 0 0 0 0 0 0 2 1 0.000
양준혁 2003.04.22 기아 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0.000
진갑용 2003.04.26 LG 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0.000
진갑용 2003.04.26 LG 4 4 0 0 0 0 0 0 0 0 0 0 0 1 0.000
진갑용 2003.04.24 기아 4 2 0 1 0 0 0 0 0 0 2 0 0 0 0.500
진갑용 2003.04.22 기아 3 2 0 2 1 0 0 0 0 0 0 1 0 0 1.000
진갑용 2003.04.19 SK 4 4 1 1 0 0 0 1 1 0 0 0 2 0 0.250
강명구 2003.04.24 기아 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.000
강명구 2003.04.17 현대 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0.000
강명구 2003.04.15 현대 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.000
강명구 2003.04.11 한화 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0.000
예) 자료결합 종합예제
* c:\sas\myprog\datamanip.sas;
/* Basic Data set manipulation;
SET DELETE DROP PRINT IN= LIST OPTIONS
MERGE BY FIRST. LAST. UPDATE KEEP= TITLE
1. Read permament SAS data set
2. Taking a subset of the observations
3. Taking a subset of the variables
4. Adding new variables
5. Combining several operations
6. Multiple output data sets
7. Concatenation
8. Interleaving
9. Merging
10. Updating */
dm 'log; clear; output; clear';
OPTIONS LS=72 nocenter nodate nonumber;
TITLE;
libname c 'c:\sas\myprog';
DATA body;
set c.body(obs=20);
if gender =1 then sex= 'M'; else sex = 'F';
if height > 158;
keep id age sex height weight;
PROC PRINT; TITLE 'Original data set';
DATA b; SET body; IF sex='M' THEN DELETE;
PROC PRINT; TITLE 'Subset of observations: Female';
DATA C; SET body; DROP height weight;
PROC PRINT; TITLE 'Subset of variables: DROP weight height';
DATA d; SET body; birthyr=2000-age;
PROC PRINT; TITLE 'Adding a new wariable';
DATA e; SET body;
IF sex='M' THEN DELETE;
DROP height weight;
birthyr=2000-age;
PROC PRINT; TITLE 'Combining several operations';
DATA males females; KEEP id;
SET body;
IF sex='M' THEN OUTPUT males;
IF sex='F' THEN OUTPUT females;
PROC PRINT DATA=males; TITLE 'males - First output data set';
PROC PRINT DATA=females; TITLE 'females - second output data set';
DATA both;
SET males(IN=m) females(IN=f);
IF m THEN sex='M'; IF f THEN sex='F';
PROC PRINT; TITLE 'Concatenated data sets';
DATA both;
SET males(IN=m) females(IN=f); BY id;
IF m THEN sex='M'; IF f THEN sex='F';
PROC PRINT; TITLE 'Interleaved data set';
DATA library; INPUT id date textbook $12.; CARDS;
4 2 English
6 2 Science
6 3 English
7 1 Art
11 4 Arithematic
12 5 Sewing
15 2 Art
17 1 Mechanics
19 2 Science
PROC PRINT; TITLE 'Library transaction data set';
DATA newbody;
MERGE body(IN=C) library; BY id;
IF C & LAST.id;
PROC PRINT;
TITLE 'For each person what is the most recently checked book?';
DATA newlib;
MERGE library(IN=l) body(KEEP=id age sex); BY id;
IF l;
PROC PRINT;
TITLE 'For each library transaction, what is the the age and sex of cheker';
DATA transact;
INPUT id sex $ age height weight comment $ 24-50; LIST; CARDS;
20 . . 170 75 Update new height weight
41 F 13 160 55 Additional record
72 M 13 170 60 Additional record
PROC PRINT; TITLE 'Transactions'; RUN;
DATA body2;
UPDATE body transact(drop=comment); BY id;
PROC PRINT; TITLE 'New updated master file'; RUN;
  • 가격2,000
  • 페이지수17페이지
  • 등록일2003.12.17
  • 저작시기2003.12
  • 파일형식한글(hwp)
  • 자료번호#238805
본 자료는 최근 2주간 다운받은 회원이 없습니다.
다운로드 장바구니