Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: (st) Automatical aggregation from 4 digit codes to 3,2 digit codes?


From   [email protected]
To   stata <[email protected]>
Subject   st: (st) Automatical aggregation from 4 digit codes to 3,2 digit codes?
Date   Wed, 22 Nov 2006 16:14:15 -0700

Hello. Stata Users.
I need your help.
I have panel set containing ID(4 digit), year and Var1, for simple case.
I just want to add 2 or 3 digit level Var1 using aggregating up 4-digit level
coded. For example, Currently my dataset looks like (from sort by year id)

 ID   year   var1
 1111   72    2
 1112   72    1
 1113   72    4
 1121   72    3
   .     .    .
  ..     ..   ..

 1111   73     1
 1112   73     2
 1113   73     3
 1121   72     4


 I would like to add var1 as follows:

 ID     year     var1
 11     72     ???(7+??+....)
 111    72     7 (2+1+3)
 1111   72     2
 1112   72     1
 1113   72     4
 112    72     ?? (3+?+?...)
 1121   72     3
   .     .    .
  ..     ..   ..
 11     73     ?? (6+?)
 111    73     6 (1+2+3)
 1111   73     1
 1112   73     2
 1113   73     3
 112    73     ? (4+..)
 1121   72     4


As you see, the aggregating values should be added by year and ID.
Since I have lot of codes, it would take forever to generate each 3 and 2 digit
level manually. It is possible way to create automatically 3 and 2 digit level
code and following new var1 in the system?
Thanks. Any comments and helpful remarks should be appreciated
WT





*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index