°³ÀÎÀÚ·á¿¡¼ »çȸº¸Àå±Þ¿©´Â °³ÀÎÀÌ ¹Þ°í ÀÖ´Â ±Þ¿©ÀÇ °³¼ö¿¡ µû¶ó ±Þ¿©Á¾·ù 1¿¡¼ ±Þ¿©Á¾·ù 5±îÁö ³ª¿µÇ¾î ÀÖ´Ù. µû¶ó¼ ƯÁ¤ »çȸº¸Àå±Þ¿©¸¦ ¼ö±ÞÇÏ°í ÀÖ´Â ÄÉÀ̽º¸¦ ÃßÃâÇÒ °æ¿ì¿¡´Â ³ª¿µÇ¾î ÀÖ´Â º¯¼ö ¸ðµÎ¸¦ °í·ÁÇÏ¿© ÃßÃâÇÒ ÇÊ¿ä°¡ ÀÖ´Ù.
¿¹¸¦ µé¾î 7Â÷³âµµ °³ÀÎÀڷḦ È°¿ëÇÏ¿© ±âÃÊ¿¬±Ý(ºÎºÎ)À» ¼ö±Þ ¹Þ°í ÀÖ´Â °³ÀÎÀ» ÃßÃâÇÒ °æ¿ì, ÇÁ·Î±×·¥Àº ´ÙÀ½°ú °°ÀÌ ±¸¼ºµÈ´Ù.
/* sas array¹®ÀÇ È°¿ë*/
data a; set k.kreisp07;
keep pid w07psvy p07g036 p07g039 p07g042 p07g045 p07g048 base;
where w07psvy=1; /*7Â÷¿¡ ÀÀ´äÇÑ °³Àε鸸 ÃßÃâ*/
array a[5] p07g036 p07g039 p07g042 p07g045 p07g048; /*»çȸº¸Àå±Þ¿©Á¾·ù 1-5 Á¤·Ä*/
do i=1 to 5;
if a[i]=162 then base=162; /*±âÃÊ¿¬±Ý(ºÎºÎ) ¼ö±ÞÀÚ¸¦ ÃßÃâ*/
end;
run;
/* spss repeat¹®ÀÇ È°¿ë*/
get file='D:\KReIS\SPSS\kreisp07.sav'.
select if (w07psvy = 1). /*7Â÷¿¡ ÀÀ´äÇÑ °³Àε鸸 ÃßÃâ*/
exe.
do repeat
g=p07g036 p07g039 p07g042 p07g045 p07g048. /*»çȸº¸Àå±Þ¿©Á¾·ù 1-5 Á¤·Ä*/
if (g=162) p07g=g. /*±âÃÊ¿¬±Ý(ºÎºÎ) ¼ö±ÞÀÚ¸¦ ÃßÃâ*/
end repeat.
exe.
/* stata foreach¹®ÀÇ È°¿ë*/
clear
set mem 300m
use "D:\KReIS\STATA\kreisp07.dta", clear
keep if w07psvy==1 /*7Â÷¿¡ ÀÀ´äÇÑ °³Àε鸸 ÃßÃâ*/
gen base=.
keep pid w07psvy p07g036 p07g039 p07g042 p07g045 p07g048 base
local k=1 /*»çȸº¸Àå±Þ¿©Á¾·ù 1-5 Á¤·Ä*/
foreach g of varlist p07g036-p07g048 {
rename `g' g`k'
local ++k
}
foreach n of num 1/5 {
replace base=g`n' if g`n'==162
} /*±âÃÊ¿¬±Ý(ºÎºÎ) ¼ö±ÞÀÚ¸¦ ÃßÃâ*/
save "D:\KReIS\STATA\a.dta", replace