[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Re: Reshape related
From
"Martin Weiss" <[email protected]>
To
<[email protected]>
Subject
st: Re: Reshape related
Date
Sat, 22 Nov 2008 23:19:21 +0100
Remember when you -generate- you add a whole column to your dataset which
may or may not be what you want. Sometimes it is preferable to
just -generate newvar=.- and then add values by -replace newvar=5 in 1- and
so on. Apart from this general advice, you are not looking for a "function"
but for the -if- qualifier, as far as I can tell from your description of
your problem. See -h if-
HTH
Martin
_______________________
----- Original Message -----
From: "Kir1" <[email protected]>
To: <[email protected]>
Sent: Saturday, November 22, 2008 11:12 PM
Subject: st: Reshape related
Hi All,
Perhaps the subject line is not the best one to address my problem,
but here it is:
My original data set is of the 'long' format like this
gvkey year revenue
1000 1999 111
1000 2000 222
.
.
1001 1999 888
From this I want to retrieve only one value of revenue per 'gvkey'
which corresponds to a year value that i lookup in a different
database. So if in the other data base my gvkey is 1000 and lookupyear
is 2000, then only 222 should be in the revenue cell of the final
database.
I can think of numerous inelegant ways to do this using Excel. But the
most elegant solution would be (i think) something like this.
step 1: reshape to wide: so the data now looks like this
gvkey revenue1999 revenue2000.....
1000 111 222
1001 888
step 2: gen singlerev = the value contained in the cell whose name is
("revenue" +"lookupyear")
The problem I have is finding the function that does this:" the value
contained in the cell whose name is ("revenue" +"lookupyear") )
Any help is appreciated. Any simpler way to do this is even more
appreciated.
Thanks
Kiron
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
© Copyright 1996–2025 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |