Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: help on expanding data


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: help on expanding data
Date   Fri, 18 Mar 2005 12:43:25 -0000

expand 3 if  services == "ALL"

bysort customer (services) : 
	replace services = word("1DA 2DA 3DS", _n) if services == "ALL"

Nick 
n.j.cox@durham.ac.uk 

MITRA PINAKI
 
> I have a data set like the following:
> Customer	Services	Rate
> xx1		1DA		.50
> xx1		2DA		.75
> xx2		ALL		.30
> xx3		2DA		.40
> xx3		3DS		.60
> and so on.
> 
> The maximum combination of services can be (1DA, 2DA, 3DS) 
> and when the
> services is "ALL", I need the data set to be expanded in 1DA, 2DA, 3DS
> with the same rate. So for customer xx2, it needs to look like:
> 
> Customer	Services	Rate
> xx2		1DA		.30
> xx2		2DA		.30
> xx2		3DS		.30
> while all other information for other customers remains same. 

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index