Here’s an overview of the dataset. The excel spreadsheet consists of several sheets. Each sheet has yearly time series data on one variable for several states across time from 1945 till 1978. For example, sheet1 has data on var1. The columns indicate the states and the rows correspond to the time periods. I’ve attached a hypothetical data for your reference which has 3 variables – var1, var2, var3
How can I rearrange (or stack) the dataset that is compatible to perform panel regression analysis? Before estimating a fixed effects model, I have to group the states in 3 categories
Group1: states MA, CA, NY
Group2: states, TX, WY
Group3: states, WA, TN, RI
Since there are three sheets in the excel spradsheet, perhaps a for loop might work?
So far, I've been manually rearranging the columns in excel, but that is very tedious especially if there are a large number of columns. Is there a way we can implement this via code by writing a function or something else? If you wouldn’t mind providing a sample code, I would really appreciate it. Thanks a ton.