Page 1 of 1

Pagestruct?

Posted: Thu Jul 31, 2014 3:15 pm
by startz
I need to restructure my data. I think I should be using the pagestruct command (I want to do this in a program), but don't quite see how.
I have an unstructured data file with about 11,000 observations. Each observation has a variable STDNTID which identifies a unique student number. I also have variables of the form gkclasstype, g1classtype, g2classtype, g3classtype which define the type of class in grades K-3.

I want a panel with the student number as one dimension and the grade as the other. Then I want a new variable CLASSTYPE which "stacks" the four variables g?classtype. (Of course, I have more variables than just this one to be stacked.)

I suspect that this is one or two lines of code, but I'm not seeing it.

Re: Pagestruct?

Posted: Thu Jul 31, 2014 3:31 pm
by EViews Gareth
Not 100% certain I follow, but something like this:

Code: Select all

create u 11000 series STDNTID = @trend+1000 series gkclasstype=nrnd series g1classtype=nrnd series g2classtype=nrnd series g3classtype=nrnd pagestack gk g1 g2 g3 @ ?* rename id01 stdntid rename var01 class pagestruct class stdntid

Re: Pagestruct?

Posted: Fri Aug 01, 2014 8:52 am
by startz
Thanks Gareth. This gets me most of what I need.

I also have variables in the original page that are constant with regard to class, such as student id, birthmonth, etc. Presumably I need to copy them to the new page matching on student id and expanding across class. There are two pieces I don't see how to do.

(1) After the pagestruck, how do I use the copy command to get the merge done right?
(2) How do I do whatever the answer is to (1), when the student id isn't yet in the new page?

edit after a little more investigation...
I see I can go

Code: Select all

copy oldpage\birthmonth newpage\birthmonth stdntid stdntid
but is there a way to copy multiple series or do I need a copy command for each individual series?

I've managed to manually construct student id in the new page, but is there a "right" way to do it?

Re: Pagestruct?

Posted: Fri Aug 01, 2014 9:42 am
by startz
The commands

Code: Select all

pagestack(page=reorgSTAR,interleave) gk g1 g2 g3 @ ?* series stdntid = id01 + 9999 rename var01 class pagestruct stdntid class
give the basic right structure, except that the panel is ordered G1 G2 G3 GK rather than GK G1 G2 G3. It's important that kindergarten comes first! Is there a way around this, other than something like recoding "GK' to be "G0"?