Á¦¸ñ
°¡±¸¿ë µ¥ÀÌÅ͸¦ ȾÀ¸·Î ¿¬µµ °£ ¸ÓÁöÇÏ´Â ¹æ¹ý
ÀÛ¼ººÎ¼­
ÆгÎÁ¶»çÆÀ
µî·ÏÀÏ
2011/01/03
Á¶È¸¼ö
2843
³»¿ë
 

±¹¹Î³ëÈĺ¸ÀåÆгÎÁ¶»ç¿¡¼­´Â 1~3Â÷³âµµ °¡±¸ µ¥ÀÌÅ͸¦ ȾÀ¸·Î ¸ÓÁöÇÑ µ¥ÀÌÅÍ(KReISHW)¸¦ Á¦°øÇÏ°í ÀÖ´Ù. ÀÌ °æ¿ì °¢ ³âµµ¿¡¼­ ÁøÀÔÂ÷¼ö°¡ °°Àº °¡±¸ÀÇ ÇØ´ç ÁøÀÔÂ÷¼ö °¡±¸¹øÈ£¸¦ ±âÁØÀ¸·Î ¸ÓÁöÇÑ µÚ ¼­·Î ´Ù¸¥ ÁøÀÔÂ÷¼öÀÇ µ¥ÀÌÅ͸¦ ÇÕÃÄÁØ´Ù.


  ¿¹¸¦ µé¾î 1~3Â÷³âµµ °¡±¸ÀڷḦ ȾÀ¸·Î ¸ÓÁöÇÏ´Â °æ¿ì, ´ÙÀ½°ú °°Àº ÀýÂ÷¸¦ µû¸¥´Ù.


¨ç 1~3Â÷³âµµ °¡±¸ÀÚ·á¿¡¼­ °¢°¢ ÁøÀÔÂ÷¼ö (hent)°¡ 1ÀÎ ÄÉÀ̽º¸¦ ÃßÃâÇÑ ÈÄ w01hid¸¦ ±âÁØÀ¸·Î Á¤·ÄÇÑ µÚ mergeÇÑ´Ù.

¨è 2Â÷, 3Â÷³âµµ °¡±¸ÀÚ·á¿¡¼­ °¢°¢ ÁøÀÔÂ÷¼ö (hent)°¡ 2ÀÌ°í 2Â÷³âµµ¿¡ Á¶»ç Âü¿©ÇÑ ÄÉÀ̽º¸¦ ÃßÃâÇÑ ÈÄ w02hid¸¦ ±âÁØÀ¸·Î Á¤·ÄÇÑ µÚ mergeÇÑ´Ù.

¨é 3Â÷³âµµ °¡±¸ ÀÚ·á¿¡¼­ ÁøÀÔÂ÷¼ö(hent)°¡ 3À̰ųª 2Â÷³âµµ ÁøÀÔÇÏ¿´À¸³ª 2Â÷³âµµ¿¡ Á¶»ç Âü¿©ÇÏÁö ¾ÊÀº ÄÉÀ̽º¸¦ ÃßÃâÇÑ´Ù.

¨ê À§ÀÇ °á°ú ¸¸µé¾îÁø ¼¼ °³ÀÇ µ¥ÀÌÅ͸¦ Á¾À¸·Î ÇÕÄ£´Ù.



/* sas Merge¹®, Append¹®ÀÇ È°¿ë */

data k01; set k.kreish01;      /*1Â÷³âµµ µ¥ÀÌÅÍ¿¡¼­ ÇÊ¿äÇÑ º¯¼ö¸¸ ÃßÃâ */

keep hid w01hid hent h01d001 h01d002;

if hent=1; run;              /*ÁøÀÔÂ÷¼ö°¡ 1ÀÎ ÄÉÀ̽º¸¸ ÃßÃâ*/

proc sort; by hid; run;


data k02; set k.kreish02;      /*2Â÷³âµµ µ¥ÀÌÅÍ¿¡¼­ ÇÊ¿äÇÑ º¯¼ö¸¸ ÃßÃâ */

keep hid w02hid hent h02d001 h02d002;

if hent=1; run;              /*ÁøÀÔÂ÷¼ö°¡ 1ÀÎ ÄÉÀ̽º¸¸ ÃßÃâ*/

proc sort; by hid; run;


data k03; set k.kreish03;     /*3Â÷³âµµ µ¥ÀÌÅÍ¿¡¼­ ÇÊ¿äÇÑ º¯¼ö¸¸ ÃßÃâ */

keep hid w01hid w02hid w03hid hent w01hsvy w02hsvy w03hsvy  h03d001 h03d002; 

if hent=1; run;              /*ÁøÀÔÂ÷¼ö°¡ 1ÀÎ ÄÉÀ̽º¸¸ ÃßÃâ*/

proc sort; by hid; run;


data t1; merge k01 k02 k03; by hid; run;    /*ÁøÀÔÂ÷¼ö°¡ 1ÀÎ °¡±¸ÀڷḦ ¸ÓÁö*/  


data k02_1; set k.kreish02;       /*2Â÷³âµµ µ¥ÀÌÅÍ¿¡¼­ ÇÊ¿äÇÑ º¯¼ö¸¸ ÃßÃâ */

keep hid w02hid hent h02d001 h02d002;   

if hent=2; run;                 /*ÁøÀÔÂ÷¼ö°¡ 2ÀÎ ÄÉÀ̽º¸¸ ÃßÃâ*/

proc sort; by w02hid; run;


data k03_1; set k.kreish03;        /*3Â÷³âµµ µ¥ÀÌÅÍ¿¡¼­ ÇÊ¿äÇÑ º¯¼ö¸¸ ÃßÃâ */

keep hid w01hid w02hid w03hid hent w01hsvy w02hsvy w03hsvy  h03d001 h03d002;

if hent=2 & w02hsvy=1; run;     /*2Â÷³âµµ Á¶»ç Âü¿©ÇÏ°í ÁøÀÔÂ÷¼ö°¡ 1ÀÎ ÄÉÀ̽º¸¸ ÃßÃâ*/

proc sort; by w02hid; run;


data t2; merge k02_1 k03_1;

by w02hid;run;                      /*ÁøÀÔÂ÷¼ö°¡ 2ÀÎ °¡±¸ÀڷḦ ¸ÓÁö*/ 


data t3; set k.kreish03;

keep hid w01hid w02hid w03hid hent w01hsvy w02hsvy w03hsvy  h03d001 h03d002;

if hent=3 or (hent=2 & w02hsvy=2); run;   /*ÁøÀÔÂ÷¼ö°¡ 3À̰ųª 2Â÷³âµµ Á¶»ç Âü¿©ÇÏÁö ¾ÊÀº ÁøÀÔÂ÷¼ö°¡ 2ÀÎ ÄÉÀ̽º ÃßÃâ*/


data hw;

retain hid w01hid w02hid w03hid hent w01hsvy w02hsvy w03hsvy h01d001 h01d002 h02d001 h02d002 h03d001 h03d002;      /*º¯¼ö ¼ø¼­ Á¤¸®*/

set t1 t2 t3; run;             /*°¢ ÁøÀÔÂ÷¼öº°·Î ¸ÓÁöÇÑ µ¥ÀÌÅ͸¦ Á¾À¸·Î ÇÕÄ£´Ù*/



/* spss Match¹®, Add¹®ÀÇ È°¿ë */


get file='D:\KReIS\SPSS\kreish01.sav'

/keep=hid w01hid hent h01d001 h01d002.    /*1Â÷³âµµ µ¥ÀÌÅÍ¿¡¼­ ÇÊ¿äÇÑ º¯¼ö¸¸ ÃßÃâ */

sort cases by hid.

select if hent=1.                            /*ÁøÀÔÂ÷¼ö°¡ 1ÀÎ ÄÉÀ̽º¸¸ ÃßÃâ*/

save out ='D:\KReIS\SPSS\k01.sav'

compressed.


get file='D:\KReIS\SPSS\kreish02.sav'

/keep=hid w02hid hent h02d001 h02d002.    /*2Â÷³âµµ µ¥ÀÌÅÍ¿¡¼­ ÇÊ¿äÇÑ º¯¼ö¸¸ ÃßÃâ */

sort cases by hid.

select if hent=1.                             /*ÁøÀÔÂ÷¼ö°¡ 1ÀÎ ÄÉÀ̽º¸¸ ÃßÃâ*/

save out ='D:\KReIS\SPSS\k02.sav'

compressed.


get file='D:\KReIS\SPSS\kreish03.sav'         /*3Â÷³âµµ µ¥ÀÌÅÍ¿¡¼­ ÇÊ¿äÇÑ º¯¼ö¸¸ ÃßÃâ */

/keep=hid w01hid w02hid w03hid hent w01hsvy w02hsvy w03hsvy  h03d001 h03d002.

sort cases by hid.

select if hent=1.                             /*ÁøÀÔÂ÷¼ö°¡ 1ÀÎ ÄÉÀ̽º¸¸ ÃßÃâ*/

save out ='D:\KReIS\SPSS\k03.sav'

compressed.


match files /file='D:\KReIS\SPSS\k01.sav'     /*ÁøÀÔÂ÷¼ö°¡ 1ÀÎ °¡±¸ÀڷḦ ¸ÓÁö*/  

/file='D:\KReIS\SPSS\k02.sav'

/file='D:\KReIS\SPSS\k03.sav'

/by hid.

exe.

save out ='D:\KReIS\SPSS\t1.sav'

compressed.


get file='D:\KReIS\SPSS\kreish02.sav'

/keep=hid w02hid hent h02d001 h02d002.      /*2Â÷³âµµ µ¥ÀÌÅÍ¿¡¼­ ÇÊ¿äÇÑ º¯¼ö¸¸ ÃßÃâ */

sort cases by w02hid.

select if hent=2.                               /*ÁøÀÔÂ÷¼ö°¡ 2ÀÎ ÄÉÀ̽º¸¸ ÃßÃâ*/

save out ='D:\KReIS\SPSS\k02_1.sav'

compressed.


get file='D:\KReIS\SPSS\kreish03.sav'           /*3Â÷³âµµ µ¥ÀÌÅÍ¿¡¼­ ÇÊ¿äÇÑ º¯¼ö¸¸ ÃßÃâ */

/keep=hid w01hid w02hid w03hid hent w01hsvy w02hsvy w03hsvy h03d001 h03d002.

sort cases by w02hid.

select if hent=2 & w02hsvy=1.           /*2Â÷³âµµ Á¶»ç Âü¿©ÇÏ°í ÁøÀÔÂ÷¼ö°¡ 1ÀÎ ÄÉÀ̽º¸¸ ÃßÃâ*/

save out ='D:\KReIS\SPSS\k03_1.sav'

compressed.


match files /file='D:\KReIS\SPSS\k02_1.sav'     /*ÁøÀÔÂ÷¼ö°¡ 2ÀÎ °¡±¸ÀڷḦ ¸ÓÁö*/ 

/file='D:\KReIS\SPSS\k03_1.sav'

/by w02hid.

exe.

save out ='D:\KReIS\SPSS\t2.sav'

compressed.


/*ÁøÀÔÂ÷¼ö°¡ 3À̰ųª 2Â÷³âµµ Á¶»ç Âü¿©ÇÏÁö ¾ÊÀº ÁøÀÔÂ÷¼ö°¡ 2ÀÎ ÄÉÀ̽º ÃßÃâ*/

get file='D:\KReIS\SPSS\kreish03.sav'

/keep=hid w01hid w02hid w03hid hent w01hsvy w02hsvy w03hsvy h03d001 h03d002.

sort cases by w03hid.

select if hent=3 or (hent=2 & w02hsvy=2).

save out ='D:\KReIS\SPSS\t3.sav'

compressed.

add files /file='D:\KReIS\SPSS\t1.sav'      /*°¢ ÁøÀÔÂ÷¼öº°·Î ¸ÓÁöÇÑ µ¥ÀÌÅ͸¦ Á¾À¸·Î ÇÕÄ£´Ù*/

/file='D:\KReIS\SPSS\t2.sav'

/file='D:\KReIS\SPSS\t3.sav'.

exe.

save out ='D:\KReIS\SPSS\hw.sav'

compressed.


get file='D:\KReIS\SPSS\hw.sav'           /*º¯¼ö ¼ø¼­ Á¤¸®*/

/keep=hid w01hid w02hid w03hid hent w01hsvy w02hsvy w03hsvy h01d001 h01d002 h02d001 h02d002 h03d001 h03d002.

save out ='D:\KReIS\SPSS\hw.sav'

compressed.



/* stata Merge¹®, append¹®ÀÇ È°¿ë */


clear

set mem 300m

use "D:\KReIS\STATA\kreish01.dta", clear

keep hid w01hid hent h01d001 h01d002     /*1Â÷³âµµ µ¥ÀÌÅÍ¿¡¼­ ÇÊ¿äÇÑ º¯¼ö¸¸ ÃßÃâ */

keep if hent==1                            /*ÁøÀÔÂ÷¼ö°¡ 1ÀÎ ÄÉÀ̽º¸¸ ÃßÃâ*/

sort hid

save "D:\KReIS\STATA\k01.dta", replace


use "D:\KReIS\STATA\kreish02.dta", clear

keep hid w02hid hent h02d001 h02d002     /*2Â÷³âµµ µ¥ÀÌÅÍ¿¡¼­ ÇÊ¿äÇÑ º¯¼ö¸¸ ÃßÃâ */

keep if hent==1                            /*ÁøÀÔÂ÷¼ö°¡ 1ÀÎ ÄÉÀ̽º¸¸ ÃßÃâ*/

sort hid

save "D:\KReIS\STATA\k02.dta", replace


use "D:\KReIS\STATA\kreish03.dta", clear      /*3Â÷³âµµ µ¥ÀÌÅÍ¿¡¼­ ÇÊ¿äÇÑ º¯¼ö¸¸ ÃßÃâ */

keep hid w01hid w02hid w03hid hent w01hsvy w02hsvy w03hsvy h03d001 h03d002

keep if hent==1                               /*ÁøÀÔÂ÷¼ö°¡ 1ÀÎ ÄÉÀ̽º¸¸ ÃßÃâ*/

sort hid


merge hid using "D:\KReIS\STATA\k02.dta" "D:\KReIS\STATA\k01.dta", unique sort

tab _merge                                 /*ÁøÀÔÂ÷¼ö°¡ 1ÀÎ °¡±¸ÀڷḦ ¸ÓÁö*/

save "D:\KReIS\STATA\t1.dta", replace


use "D:\KReIS\STATA\kreish02.dta", clear

keep hid w02hid hent h02d001 h02d002        /*2Â÷³âµµ µ¥ÀÌÅÍ¿¡¼­ ÇÊ¿äÇÑ º¯¼ö¸¸ ÃßÃâ */

keep if hent==2                               /*ÁøÀÔÂ÷¼ö°¡ 2ÀÎ ÄÉÀ̽º¸¸ ÃßÃâ*/   

sort w02hid

save "D:\KReIS\STATA\k02_1.dta", replace


use "D:\KReIS\STATA\kreish03.dta", clear /*3Â÷³âµµ µ¥ÀÌÅÍ¿¡¼­ ÇÊ¿äÇÑ º¯¼ö¸¸ ÃßÃâ */

keep hid w01hid w02hid w03hid hent w01hsvy w02hsvy w03hsvy h03d001 h03d002

keep if hent==2 & w02hsvy==1           /*2Â÷³âµµ Á¶»ç Âü¿©ÇÏ°í ÁøÀÔÂ÷¼ö°¡ 1ÀÎ ÄÉÀ̽º¸¸ ÃßÃâ*/

sort w02hid


merge w02hid using "D:\KReIS\STATA\k02_1.dta", unique sort 

tab _merge                              /*ÁøÀÔÂ÷¼ö°¡ 2ÀÎ °¡±¸ÀڷḦ ¸ÓÁö*/

save "D:\KReIS\STATA\t2.dta", replace


/*ÁøÀÔÂ÷¼ö°¡ 3À̰ųª 2Â÷³âµµ Á¶»ç Âü¿©ÇÏÁö ¾ÊÀº ÁøÀÔÂ÷¼ö°¡ 2ÀÎ ÄÉÀ̽º ÃßÃâ*/

use "D:\KReIS\STATA\kreish03.dta", clear

keep hid w01hid w02hid w03hid hent w01hsvy w02hsvy w03hsvy h03d001 h03d002

keep if hent==3 | (hent==2 & w02hsvy==2)

save "D:\KReIS\STATA\t3.dta", replace

use "D:\KReIS\STATA\t1.dta", clear   /*°¢ ÁøÀÔÂ÷¼öº°·Î ¸ÓÁöÇÑ µ¥ÀÌÅ͸¦ Á¾À¸·Î ÇÕÄ£´Ù*/

append using "D:\KReIS\STATA\t2.dta"

append using "D:\KReIS\STATA\t3.dta"

keep hid w01hid w02hid w03hid hent w01hsvy w02hsvy w03hsvy h01d001 h01d002 h02d001 h02d002 h03d001 h03d002

order hid w01hid w02hid w03hid hent w01hsvy w02hsvy w03hsvy h01d001 h01d002 h02d001 h02d002 h03d001 h03d002               /*º¯¼ö ¼ø¼­ Á¤¸®*/

save "D:\KReIS\STATA\hw.dta", replace

¸ñ·Ï
´ÙÀ½±Û
°³ÀÎ¿ë µ¥ÀÌÅ͸¦ ȾÀ¸·Î ¿¬µµ°£ ¸ÓÁöÇÏ´Â ¹æ¹ý (7Â÷ ±âÁØ)
ÀÌÀü±Û
FAQÀÇ ¿¹Á¦ ÇÁ·Î±×·¥¿¡¼­ ÀڷḦ ºÒ·¯¿À±â À§ÇÑ °æ·Î ÁöÁ¤ ¹æ¹ý