Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 73262

Expand data based on a time variable

$
0
0
Dear Statalisters,

Below is my data (show the first two records). Ticker, cname, and permno identify the company and its stock issue code. I want to expand each row into month and year, that is for GFGC, I want to have add rows for dec 1985, jan 1986, feb 1986, till dec 2014. I guess I need a year and month variable. I wonder if I need to reshape the data. It is a little complicated for me to clearly outline the programming step. Could someone help?

Startdate and enddate are long, format %d

Data have
input str6 ticker str32 cname permno startdate enddate
GFGC GAS NATURAL INC 10001 31-Dec-85 31-Dec-14
BTFG BANCTRUST FINANCIAL GROUP INC 10002 31-Dec-85 28-Feb-13
end

Data want

input str6 ticker str32 cname permno year month
GFGC GAS NATURAL INC 10001 1985 12
GFGC GAS NATURAL INC 10001 1986 1
GFGC GAS NATURAL INC 10001 1986 2
....
GFGC GAS NATURAL INC 10001 2014 12


Regards,
​Rochelle

Viewing all articles
Browse latest Browse all 73262

Trending Articles