Hello All,
I have a dataset like the following and need to create a new variable
(identifier) based on the value of the occurrence. The data set is by
pkgNo and customer. These pkgs. are in sequence which indicate they are
from the same source and I need to flag them by the first pkgNo. for the
occurrence. For example, the first 4 obs. are from one source which have
the value of occurrence = 4 for all 4 obs. I need to create the flag
"Identifier" which will contain the value of the first obs. when
occurrence=4 for the entire source ("1ZA20F980340070869"). Obs. 5 and 6
are from the different sources since the value of the occurrence = 1.
Obs. 7 and 8 are from the same sources since the value of the occurrence
= 2 (greater than 1) and the value of the Identifier need to be
1ZXX11220340721282, and so on.
-------------
Customer PkgNo occurrence Identifier (new variable)
A20F98 1ZA20F980340070869 4 1ZA20F980340070869
A20F98 1ZA20F980341667473 4 1ZA20F980340070869
A20F98 1ZA20F980340721281 4 1ZA20F980340070869
A20F98 1ZA20F980340376299 4 1ZA20F980340070869
A20F98 1ZA20F980340721282 1 1ZA20F980340721282
A20F98 1ZA20F980340376200 1 1ZA20F980340376200
XX1122 1ZXX11220340721282 2 1ZXX11220340721282
XX1122 1ZXX11220340376200 2 1ZXX11220340721282
XX1133 1ZXX11330340721284 1 1ZXX11330340721284
XX1133 1ZXX11330340376255 1 1ZXX11330340376255
--------------
I can't figure out a way to tackle this problem. Can someone please
provide me any help?
Thank you,
Pinaki Mitra
*
* 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/