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

st: re: panel data manipulation

From   "Dev Vencappa" <[email protected]>
To   <[email protected]>
Subject   st: re: panel data manipulation
Date   Mon, 16 May 2005 11:26:29 +0100

 I am sorry I forgot to mention it but levels is a user written command that you will need to download. I apologise for  the writings on the efficiency scores: I took the code from one of my do files. I had to do something similar to what you want about 5 days ago, so I almost copied it straight into the mail. I still think the following coding works.YOu will end up with a variable called quartile that will be split into 4 categories (1,2,3,4). Give it a go if you have not been successful yet (don't forget to change the variable companyname to what it is called in your data set (+make adjustments if it is a string variable: that would only require you to write: companyname=="`k'" when calling each one), and change the years accordingly.

*create the quartile variable first

gen quartile=.

*assuming you are creating 4 quartiles & your company is coded as numeric

 levels companyname, local(levels)
foreach k of local levels{
forvalues x=1980/1995{  /*if these are your years for example*/
centiles assets, centile(25 50 75)
replace quartile=1 if assets<=r(c_1) & companyname==`k' & year==`x'
replace quartile=2 if assets>r(c_1) & assets<=r(c_2)  & companyname==`k' & year==`x'
replace quartile=3 if assets>r(c_2) & assets<=r(c_3)  & companyname==`k' & year==`x'
replace quartile=4 if assets>r(c_3)  & companyname==`k' & year==`x'

Hope that helps.

>>> [email protected] 05/16/05 11:05 am >>>
Re my program that creates separate variables for each year: easily changed to what you want (I think)

webuse grunfeld,clear
gen allquartile = .
qui forv i=1935/1954 {
egen quartile`i' = cut(mvalue) if year==`i', group(4)
replace allquartile=quartile`i'+1 if quartile`i' < .
su allquartile

This will create a single variable for which each firm is classified in the quartile in which it falls each year (which may differ over years).

*   For searches and help try:

This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

*   For searches and help try:

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