|
Hello all,
I know enough about Varstocases to be dangerous. I have a client that wants their SPSS data set "stacked" with three variables. Two of the three variables have 2 observations, one of the variables has 9 observations. Is it possible to create a usable SPSS file in a stacked format with such dissimilarities? My understanding of this function is that it works on equal observations across multiple variables.
As always, many thanks! Jim
|
|
Your description is a bit vague. Can you provide example rows of
data. From: SPSSX(r) Discussion
[mailto:[hidden email]] On Behalf Of Jim Arnold Hello all, I know enough about Varstocases to be dangerous. I
have a client that wants their SPSS data set "stacked" with three
variables. Two of the three variables have 2 observations, one of the
variables has 9 observations. Is it possible to create a usable SPSS file
in a stacked format with such dissimilarities? My understanding of this
function is that it works on equal observations across multiple variables. As always, many thanks! Jim |
|
The data, simplified:
V1 has two observations, A & B, V2, similarly, has two observations, A & B. V3 has nine observations (A->I). I think I've answered my own question. V3 will have to be output to a separate file.
On Wed, Apr 1, 2009 at 5:28 PM, ViAnn Beadle <[hidden email]> wrote:
|
|
Ok – now what do you want the resulting stacked file to look
like? What is the real end goal? From: SPSSX(r) Discussion
[mailto:[hidden email]] On Behalf Of Jim Arnold The data, simplified:
V1 has two observations, A & B, V2, similarly, has
two observations, A & B. V3 has nine observations (A->I). I
think I've answered my own question. V3 will have to be output to
a separate file. On Wed, Apr 1, 2009 at 5:28 PM, ViAnn Beadle <[hidden email]> wrote: Your description is a bit
vague. Can you provide example rows of data. From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jim Arnold Hello all, I know enough about Varstocases to be dangerous. I have a client that
wants their SPSS data set "stacked" with three variables. Two
of the three variables have 2 observations, one of the variables has 9
observations. Is it possible to create a usable SPSS file in a stacked
format with such dissimilarities? My understanding of this function is
that it works on equal observations across multiple variables. As always, many thanks! Jim |
|
In reply to this post by Jim Arnold-3
At 06:54 PM 4/1/2009, Jim Arnold wrote:
>ID V1A V1B V2A V2B V3A V3B V3C V3D V3E V3F V3G V3H V3I >1 3 2 4 4 2 5 6 8 4 9 6 7 3 >2 1 4 5 6 3 2 5 6 7 7 7 8 5 >3 2 8 5 4 4 2 3 1 2 4 4 7 5 > >V1 has two observations, A & B, V2, similarly, has two observations, >A & B. V3 has nine observations (A->I). I think I've answered my >own question. V3 will have to be output to a separate file. It wouldn't have to be. Whether it should be, depends on what the data means. It is possible to unroll your data like this: ID case V1 V2 V3 1 1 3 4 2 1 2 2 4 3 3 . . 6 ... If you do, you're stating that there's an inherent correspondence among the 'A' values of V1, V2 and V3, such as that they were observed at the same time; that there's the same correspondence among the 'B' values; and that the 'C' through 'I' values of V3 mean the same things as the 'A' and 'B' values do, except that V1 and V2 were not observed at the times (or whatever) that those later 'C' values were observed. If that isn't true, you probably shouldn't put V1, V2 and V3 values in the same records at all. If it is true, the problem is solvable with LOOP and XSAVE. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
In reply to this post by Jim Arnold-3
Jim- I have a couple solutions for you, depending on what your data
means. If you want all the V1s in one variable, all the v2s in one
variable, and all the V3s in one variable, then this should give you want you
want: varstocases /make v1.new from v1a v1b /index = v1.id. varstocases /make v2.new from v2a v2b /index = v2.id. varstocases /make v3.new from V3A V3B
V3C V3D V3E V3F V3G V3H V3I /index = v3.id. *** This reorders the variables. match files file=* /keep ID v1.id
v2.id v3.id v1.new v2.new v3.new. And this is a sample of what you would get (108 cases total –
3 * 2 * 2 * 9) ID v1.id
v2.id v3.id v1.new v2.new v3.new
1.00 1
1 1
3.00 4.00 2.00
1.00 1
1 2
3.00 4.00 5.00
1.00 1
1 3
3.00 4.00 6.00
1.00 1
1 4
3.00 4.00 8.00
1.00 1
1 5
3.00 4.00 4.00
1.00 1
1 6
3.00 4.00 9.00
1.00 1
1 7
3.00 4.00 6.00
1.00 1
1 8
3.00 4.00 7.00
1.00 1
1 9
3.00 4.00 3.00
1.00 1
2 1
3.00 4.00 2.00
1.00 1
2 2
3.00 4.00 5.00
1.00 1
2 3
3.00 4.00 6.00 If, as Richard Ristow suggested, the letters correspond to an
observation number or something of the sort, then this syntax should give you
what you want. ** This creates and extra 7 variables
so that all 3 groups are 9 variables long. vector v1x(7,f1). vector v2x(7,f1). ** This reorders the variables. match files file=* /keep ID v1a v1b
v1x1 to v1x7 v2a v2b v2x1 to v2x7 v3a to v3i. varstocases /make V1 from v1a to v1x7 /make v2 from v2a to v2x7 /make v3 from v3a to v3i /index = Obs. And this is what you would get. ID
Obs V1
v2 v3 1.00 1
3.00 4.00 2.00
1.00 2 2.00
4.00 5.00
1.00 3
.
. 6.00
1.00 4
.
. 8.00
1.00 5
.
. 4.00
1.00 6
.
. 9.00
1.00 7
.
. 6.00
1.00 8
.
. 7.00
1.00 9
.
. 3.00
2.00 1 1.00
5.00 3.00
2.00 2 4.00
6.00 2.00
2.00 3
.
. 5.00 2.00 4
.
. 6.00
2.00 5
.
. 7.00
2.00 6
.
. 7.00
2.00 7
.
. 7.00
2.00 8
.
. 8.00
2.00 9
.
. 5.00
3.00 1 2.00
5.00 4.00
3.00 2 8.00
4.00 2.00
3.00 3
.
. 3.00
3.00 4
.
. 1.00
3.00 5
.
. 2.00
3.00 6
.
. 4.00
3.00 7
. . 4.00
3.00 8
.
. 7.00
3.00 9
.
. 5.00 Number of cases read:
27 Number of cases listed: 27 HTH, -Eric --- Eric Langston Research Analyst Human Capital Research Corporation 500 Davis Street, Suite 1002 Evanston, IL 60201 (847) 475-7580 Phone (847) 475-7584 Fax From: SPSSX(r) Discussion
[mailto:[hidden email]] On Behalf Of Jim Arnold The data, simplified:
V1 has two observations, A & B, V2, similarly, has
two observations, A & B. V3 has nine observations (A->I). I
think I've answered my own question. V3 will have to be output to
a separate file. On Wed, Apr 1, 2009 at 5:28 PM, ViAnn Beadle <[hidden email]> wrote: Your description is a bit
vague. Can you provide example rows of data. From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jim Arnold Hello all, I know enough about Varstocases to be dangerous. I have a client that
wants their SPSS data set "stacked" with three variables. Two
of the three variables have 2 observations, one of the variables has 9
observations. Is it possible to create a usable SPSS file in a stacked
format with such dissimilarities? My understanding of this function is
that it works on equal observations across multiple variables. As always, many thanks! Jim |
| Free forum by Nabble | Edit this page |
