Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: st: Doubts on how to better prepare my dataset with -reshape- and -merge_
From
Red Owl <[email protected]>
To
<[email protected]>
Subject
RE: st: Doubts on how to better prepare my dataset with -reshape- and -merge_
Date
Sun, 27 Oct 2013 16:09:26 -0400
Clarice,
I am not sure I understand what you want, but perhaps this will
do it or give you a conceptual approach:
clear
input co_id str4 ticker_name str9 return_type returnJun2000
returnJul2000 returnAug2000
1 ABCB formation 0.01 0.2 0.3
2 AEDU formation 0.01 0.2 0.3
3 AMBV formation 0.01 0.2 0.3
1 ABCB buysell 0.01 0.2 0.3
2 AEDU buysell 0.01 0.2 0.3
3 AMBV buysell 0.01 0.2 0.3
1 ABCB holding 0.01 0.2 0.3
2 AEDU holding 0.01 0.2 0.3
3 AMBV holding 0.01 0.2 0.3
end
rename return_type rtype
rename returnJun2000 return200006
rename returnJul2000 return200007
rename returnAug2000 return200008
reshape long return, i(co_id rtype) j(yrmonth)
order ticker_name, after(co_id)
sort co_id rtype
list, noobs sepby(co_id rtype) abbrev(14)
Red Owl
[email protected]
>>
>> Clarice Martins wrote:
I have:
- dataset that is wide
- i couldn't figure out how to transform it to long using -reshape-
because there is 3 variables that uniquely define an observation: co_id
(an id per company), period (a month and year period for each
observation), and type_return (there are 3 different types of return and
for each there is an observation per company, per period)
- dataset looks like this:
co_id ticker_name return_type returnJun2000 returnJul2000 returnAug2000
(and so on)
1 ABCB formation 0.01 0.2 0.3
2 AEDU formation 0.01 0.2 0.3
3 AMBV formation 0.01 0.2 0.3
1 ABCB buysell 0.01 0.2 0.3
2 AEDU buysell 0.01 0.2 0.3
3 AMBV buysell 0.01 0.2 0.3
1 ABCB holding 0.01 0.2 0.3
2 AEDU holding 0.01 0.2 0.3
3 AMBV holding 0.01 0.2 0.3
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/