12월, 2014의 게시물 표시

자릿수가 다른 일련번호 다루기

// 국내 패널자료들을 보면, 각 연차별 데이터를 일련번호를 붙이는데 01 02 03 .... 10 11 12 .... 이런 경우 순차적으로 작업하기 루프문을 돌리려면 여간 까다롭지가 않다....ㅠㅠ 이럴때 한 번 사용해 보기를....ㅋ foreach ss in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 {   di  "1을 곱한 결과 == `=`ss'*1'  ,  그렇지 않은 경우  `ss'    " } // 예를 들어,  01인 경우,   `=`ss'*1'  의   의미는  01*1=1 // 따라서 그 결과로 숫자 1을 받을 수 있다. (stata returns 1 ).... ㅋ // 별거 아닌거 같지만, 나름 유용할 듯....

STATA: Loop문의 중요성..

* 지금 아래의 코드처럼, 간혹 이렇게 길고 지루한 코드를 짜기 위해서 머리가 아픈 적은 누구나 있겠죠...  그 밑에 축약된 코드문이 있는데,.쭉 한 번 내려가 보도록 하죠, 내려가면서 그 규칙성을 한 번 생각해보면 좋아요!! ...gogo //28 replace income2031=0 if age_1999==28 //29 replace income2031=0 if age_1999==29 replace income2030=0 if age_1999==29 //30 replace income2031=0 if age_1999==30 replace income2030=0 if age_1999==30 replace income2029=0 if age_1999==30 //31 replace income2031=0 if age_1999==31 replace income2030=0 if age_1999==31 replace income2029=0 if age_1999==31 replace income2028=0 if age_1999==31 //32 replace income2031=0 if age_1999==32 replace income2030=0 if age_1999==32 replace income2029=0 if age_1999==32 replace income2028=0 if age_1999==32 replace income2027=0 if age_1999==32 //33 replace income2031=0 if age_1999==33 replace income2030=0 if age_1999==33 replace income2029=0 if age_1999==33 replace income2028=0 if age_1999==33 replace income2027=0 if age_1999==33 replace income2026=0 if age_1999==33 //34 replace income2031...