Problem with vectors

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with vectors

vlad simion
Hi everybody,
I have a data set that looks like this:

  CASE_LBL var001 var002 var003 var004 var005 var006 var007 var008 var009
var010 var011 var012  @1.00    28 72 4.8 21.6 19.2 19.2 35.2 26.4 73.6 72 28
125  @2.00    29.51 70.49 2.46 21.31 19.67 18.03 38.52 23.77 76.23 69.67
30.33 122  @3.00    30.89 69.11 4.07 20.33 18.7 20.33 36.59 24.39 75.61
69.92 30.08 123  @4.00    28.33 71.67 2.5 19.17 19.17 21.67 37.5 21.67 78.33
70 30 120  @5.00    30.08 69.92 4.07 20.33 19.51 18.7 37.4 24.39 75.61 69.92
30.08 123  @6.00    29.51 70.49 3.28 21.31 19.67 18.03 37.7 24.59 75.41
71.31 28.69 122  @7.00    30 70 3.33 20.83 19.17 18.33 38.33 24.17 75.83
70.83 29.17 120  @8.00    32.5 67.5 4.17 21.67 15.83 18.33 40 25.83 74.17
74.17 25.83 120  @9.00    27.56 72.44 3.94 19.69 18.11 19.69 38.58 23.62
76.38 71.65 28.35 127  @10.00   29.75 70.25 4.13 20.66 19.01 19.01 37.19
24.79 75.21 70.25 29.75 121  @11.00   30.08 69.92 3.25 21.14 19.51 17.89
38.21 24.39 75.61 72.36 27.64 123  @12.00   30.08 69.92 4.07 21.14 18.7 18.7
37.4 25.2 74.8 69.92 30.08 123  @13.00   30.83 69.17 3.33 18.33 20 19.17
39.17 21.67 78.33 68.33 31.67 120  @14.00   28.69 71.31 4.1 20.49 18.85
18.03 38.52 24.59 75.41 72.95 27.05 122  @15.00   30.08 69.92 4.07 20.33
17.89 18.7 39.02 24.39 75.61 71.54 28.46 123  @16.00   30.89 69.11 4.07
21.14 18.7 18.7 37.4 25.2 74.8 69.92 30.08 123  @17.00   28.93 71.07 4.13
21.49 19.01 18.18 37.19 25.62 74.38 69.42 30.58 121  @18.00   32.06 67.94
3.82 20.61 20.61 17.56 37.4 24.43 75.57 70.23 29.77 131  @19.00   30.08
69.92 4.07 21.14 18.7 18.7 37.4 25.2 74.8 70.73 29.27 123  @20.00   28.33
71.67 4.17 19.17 19.17 19.17 38.33 23.33 76.67 73.33 26.67 120  @21.00
30.33 69.67 4.92 21.31 19.67 18.03 36.07 26.23 73.77 74.59 25.41 122  @22.00
   30 70 4.17 17.5 19.17 18.33 40.83 21.67 78.33 75.83 24.17 120  mean 29.84
70.16 3.86 20.48 19 18.75 37.91 24.34 75.66 71.31 28.69 2694
and I would like to have a vector of 242 elements (number @cases=11*number
of variables=12) in which to store the following values:
first element = 29.84*125/2694
2nd element = 29.84*122/2694
3rd element =  29.84*123/2694
.............
11th element = 29.84*120/2694
12th element = 70.16*125/2694
13th element = 70.16*122/2694
............
22th element = 70.16*120/2694
...........
241th element = 28.69*122/2694
242th element = 28.69*120/2694

does anyone have any suggestions?

Many thanks.

--
Vlad Simion
Data Analyst
Tel:      +40 720130611
Reply | Threaded
Open this post in threaded view
|

Re: Problem with vectors

Spousta Jan
Hi Vlad,

There seem to be some inconsistencies in your question, as 11 * 12 is
132 and not 242 and your data has 22 cases and not 11 cases. Since 22 *
11 is equal to 242, I suppose that you think about 22 cases.

My solution is not the most elegant one, but I tried to write it as
clear as possible: Prepare the data, connect them in a simple way and
use the common vector-loop trick.

You can save the resulting variables prod1 to prod242 and merge them to
the original file or whatever you wish.

Greetings

Jan

data list free (" ", TAB) / CASE_LBL (a6) var001 (comma5.2)
var002 (comma5.2) var003 (comma5.2) var004 (comma5.2) var005 (comma5.2)
var006 (comma5.2)
var007 (comma5.2) var008 (comma5.2) var009 (comma5.2) var010 (comma5.2)
var011 (comma5.2)
var012 (comma5.2) .
begin data.
@1.00 28 72 4.8 21.6 19.2 19.2 35.2 26.4 73.6 72 28 125
@2.00 29.51 70.49 2.46 21.31 19.67 18.03 38.52 23.77 76.23 69.67 30.33
122
@3.00 30.89 69.11 4.07 20.33 18.7 20.33 36.59 24.39 75.61 69.92 30.08
123
@4.00 28.33 71.67 2.5 19.17 19.17 21.67 37.5 21.67 78.33 70 30 120
@5.00 30.08 69.92 4.07 20.33 19.51 18.7 37.4 24.39 75.61 69.92 30.08 123

@6.00 29.51 70.49 3.28 21.31 19.67 18.03 37.7 24.59 75.41 71.31 28.69
122
@7.00 30 70 3.33 20.83 19.17 18.33 38.33 24.17 75.83 70.83 29.17 120
@8.00 32.5 67.5 4.17 21.67 15.83 18.33 40 25.83 74.17 74.17 25.83 120
@9.00 27.56 72.44 3.94 19.69 18.11 19.69 38.58 23.62 76.38 71.65 28.35
127
@10.00 29.75 70.25 4.13 20.66 19.01 19.01 37.19 24.79 75.21 70.25 29.75
121
@11.00 30.08 69.92 3.25 21.14 19.51 17.89 38.21 24.39 75.61 72.36 27.64
123
@12.00 30.08 69.92 4.07 21.14 18.7 18.7 37.4 25.2 74.8 69.92 30.08 123
@13.00 30.83 69.17 3.33 18.33 20 19.17 39.17 21.67 78.33 68.33 31.67 120

@14.00 28.69 71.31 4.1 20.49 18.85 18.03 38.52 24.59 75.41 72.95 27.05
122
@15.00 30.08 69.92 4.07 20.33 17.89 18.7 39.02 24.39 75.61 71.54 28.46
123
@16.00 30.89 69.11 4.07 21.14 18.7 18.7 37.4 25.2 74.8 69.92 30.08 123
@17.00 28.93 71.07 4.13 21.49 19.01 18.18 37.19 25.62 74.38 69.42 30.58
121
@18.00 32.06 67.94 3.82 20.61 20.61 17.56 37.4 24.43 75.57 70.23 29.77
131
@19.00 30.08 69.92 4.07 21.14 18.7 18.7 37.4 25.2 74.8 70.73 29.27 123
@20.00 28.33 71.67 4.17 19.17 19.17 19.17 38.33 23.33 76.67 73.33 26.67
120
@21.00 30.33 69.67 4.92 21.31 19.67 18.03 36.07 26.23 73.77 74.59 25.41
122
@22.00 30 70 4.17 17.5 19.17 18.33 40.83 21.67 78.33 75.83 24.17 120
mean 29.84 70.16 3.86 20.48 19 18.75 37.91 24.34 75.66 71.31 28.69 2694
end data.
exe.
save outfile = "origdata.sav".

select if CASE_LBL = "mean  ".
rename var (var001 to var012 = m1 to m12).
save outfile = "meanrow.sav" /keep m1 to m11.

get file = "origdata.sav" /keep CASE_LBL var012.
temp.
select if CASE_LBL = "mean  ".
save outfile = "grandmean.sav" /keep var012 /rename var012 = grandmean.

get file = "origdata.sav" /keep CASE_LBL var012.
select if CASE_LBL ne "mean  ".
FLIP VARIABLES=var012  /NEWNAME=CASE_LBL  .
ren var (@1.00 to @22.00 = marg1 to marg22).
save outfile = "marginals.sav" /drop CASE_LBL  .

get file = "meanrow.sav" .
MATCH FILES /FILE=*
 /FILE="grandmean.sav" /FILE="marginals.sav" .
EXECUTE.

* end of data preparation.
vector m = m1 to m11.
vector marg = marg1 to marg22.
vector prod (242).
loop #i = 1 to 11.
 loop #j = 1 to 22.
  compute prod(22 * (#i - 1) + #j) = m(#i) * marg(#j) / grandmean.
 end loop.
end loop.

exe.



-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
vlad simion
Sent: Thursday, November 16, 2006 12:29 PM
To: [hidden email]
Subject: Problem with vectors

Hi everybody,
I have a data set that looks like this:

  CASE_LBL var001 var002 var003 var004 var005 var006 var007 var008
var009
var010 var011 var012  @1.00    28 72 4.8 21.6 19.2 19.2 35.2 26.4 73.6
72 28
125  @2.00    29.51 70.49 2.46 21.31 19.67 18.03 38.52 23.77 76.23 69.67
30.33 122  @3.00    30.89 69.11 4.07 20.33 18.7 20.33 36.59 24.39 75.61
69.92 30.08 123  @4.00    28.33 71.67 2.5 19.17 19.17 21.67 37.5 21.67
78.33
70 30 120  @5.00    30.08 69.92 4.07 20.33 19.51 18.7 37.4 24.39 75.61
69.92
30.08 123  @6.00    29.51 70.49 3.28 21.31 19.67 18.03 37.7 24.59 75.41
71.31 28.69 122  @7.00    30 70 3.33 20.83 19.17 18.33 38.33 24.17 75.83
70.83 29.17 120  @8.00    32.5 67.5 4.17 21.67 15.83 18.33 40 25.83
74.17
74.17 25.83 120  @9.00    27.56 72.44 3.94 19.69 18.11 19.69 38.58 23.62
76.38 71.65 28.35 127  @10.00   29.75 70.25 4.13 20.66 19.01 19.01 37.19
24.79 75.21 70.25 29.75 121  @11.00   30.08 69.92 3.25 21.14 19.51 17.89
38.21 24.39 75.61 72.36 27.64 123  @12.00   30.08 69.92 4.07 21.14 18.7
18.7
37.4 25.2 74.8 69.92 30.08 123  @13.00   30.83 69.17 3.33 18.33 20 19.17
39.17 21.67 78.33 68.33 31.67 120  @14.00   28.69 71.31 4.1 20.49 18.85
18.03 38.52 24.59 75.41 72.95 27.05 122  @15.00   30.08 69.92 4.07 20.33
17.89 18.7 39.02 24.39 75.61 71.54 28.46 123  @16.00   30.89 69.11 4.07
21.14 18.7 18.7 37.4 25.2 74.8 69.92 30.08 123  @17.00   28.93 71.07
4.13
21.49 19.01 18.18 37.19 25.62 74.38 69.42 30.58 121  @18.00   32.06
67.94
3.82 20.61 20.61 17.56 37.4 24.43 75.57 70.23 29.77 131  @19.00   30.08
69.92 4.07 21.14 18.7 18.7 37.4 25.2 74.8 70.73 29.27 123  @20.00
28.33
71.67 4.17 19.17 19.17 19.17 38.33 23.33 76.67 73.33 26.67 120  @21.00
30.33 69.67 4.92 21.31 19.67 18.03 36.07 26.23 73.77 74.59 25.41 122
@22.00
   30 70 4.17 17.5 19.17 18.33 40.83 21.67 78.33 75.83 24.17 120  mean
29.84
70.16 3.86 20.48 19 18.75 37.91 24.34 75.66 71.31 28.69 2694 and I would
like to have a vector of 242 elements (number @cases=11*number of
variables=12) in which to store the following values:
first element = 29.84*125/2694
2nd element = 29.84*122/2694
3rd element =  29.84*123/2694
.............
11th element = 29.84*120/2694
12th element = 70.16*125/2694
13th element = 70.16*122/2694
............
22th element = 70.16*120/2694
...........
241th element = 28.69*122/2694
242th element = 28.69*120/2694

does anyone have any suggestions?

Many thanks.

--
Vlad Simion
Data Analyst
Tel:      +40 720130611
Reply | Threaded
Open this post in threaded view
|

Re: Problem with vectors

vlad simion
Hi Jan,

thanks for your reply.
sorry my mistake, I have indeed 22 cases.
I tried your code and it runs perfect with no errorrs or warnings, but it
does not give any figures for vector prod in the database.
anyway I manage to do this with matrix language.
here is the code, in case someone has any ideea how it can be optimized.

matrix.
get x /var= var001 var002 var003 var004 var005 var006 var007 var008 var009
var010 var011 var012.
compute y=make(ncol(x)-1,nrow(x)-1,0).
compute base=x(nrow(x),ncol(x)).
loop i=1 to 11.
loop j=1 to 22.
compute a=x(nrow(x),i).
compute d=x(j,ncol(x)).
compute y(i,j)=a*d/base.
end loop.
end loop.
print y.
end matrix.

many thanks once again
Cheers.

vlad.

On 11/16/06, Spousta Jan <[hidden email]> wrote:

>
> Hi Vlad,
>
> There seem to be some inconsistencies in your question, as 11 * 12 is
> 132 and not 242 and your data has 22 cases and not 11 cases. Since 22 *
> 11 is equal to 242, I suppose that you think about 22 cases.
>
> My solution is not the most elegant one, but I tried to write it as
> clear as possible: Prepare the data, connect them in a simple way and
> use the common vector-loop trick.
>
> You can save the resulting variables prod1 to prod242 and merge them to
> the original file or whatever you wish.
>
> Greetings
>
> Jan
>
> data list free (" ", TAB) / CASE_LBL (a6) var001 (comma5.2)
> var002 (comma5.2) var003 (comma5.2) var004 (comma5.2) var005 (comma5.2)
> var006 (comma5.2)
> var007 (comma5.2) var008 (comma5.2) var009 (comma5.2) var010 (comma5.2)
> var011 (comma5.2)
> var012 (comma5.2) .
> begin data.
> @1.00 28 72 4.8 21.6 19.2 19.2 35.2 26.4 73.6 72 28 125
> @2.00 29.51 70.49 2.46 21.31 19.67 18.03 38.52 23.77 76.23 69.67 30.33
> 122
> @3.00 30.89 69.11 4.07 20.33 18.7 20.33 36.59 24.39 75.61 69.92 30.08
> 123
> @4.00 28.33 71.67 2.5 19.17 19.17 21.67 37.5 21.67 78.33 70 30 120
> @5.00 30.08 69.92 4.07 20.33 19.51 18.7 37.4 24.39 75.61 69.92 30.08 123
>
> @6.00 29.51 70.49 3.28 21.31 19.67 18.03 37.7 24.59 75.41 71.31 28.69
> 122
> @7.00 30 70 3.33 20.83 19.17 18.33 38.33 24.17 75.83 70.83 29.17 120
> @8.00 32.5 67.5 4.17 21.67 15.83 18.33 40 25.83 74.17 74.17 25.83 120
> @9.00 27.56 72.44 3.94 19.69 18.11 19.69 38.58 23.62 76.38 71.65 28.35
> 127
> @10.00 29.75 70.25 4.13 20.66 19.01 19.01 37.19 24.79 75.21 70.25 29.75
> 121
> @11.00 30.08 69.92 3.25 21.14 19.51 17.89 38.21 24.39 75.61 72.36 27.64
> 123
> @12.00 30.08 69.92 4.07 21.14 18.7 18.7 37.4 25.2 74.8 69.92 30.08 123
> @13.00 30.83 69.17 3.33 18.33 20 19.17 39.17 21.67 78.33 68.33 31.67 120
>
> @14.00 28.69 71.31 4.1 20.49 18.85 18.03 38.52 24.59 75.41 72.95 27.05
> 122
> @15.00 30.08 69.92 4.07 20.33 17.89 18.7 39.02 24.39 75.61 71.54 28.46
> 123
> @16.00 30.89 69.11 4.07 21.14 18.7 18.7 37.4 25.2 74.8 69.92 30.08 123
> @17.00 28.93 71.07 4.13 21.49 19.01 18.18 37.19 25.62 74.38 69.42 30.58
> 121
> @18.00 32.06 67.94 3.82 20.61 20.61 17.56 37.4 24.43 75.57 70.23 29.77
> 131
> @19.00 30.08 69.92 4.07 21.14 18.7 18.7 37.4 25.2 74.8 70.73 29.27 123
> @20.00 28.33 71.67 4.17 19.17 19.17 19.17 38.33 23.33 76.67 73.33 26.67
> 120
> @21.00 30.33 69.67 4.92 21.31 19.67 18.03 36.07 26.23 73.77 74.59 25.41
> 122
> @22.00 30 70 4.17 17.5 19.17 18.33 40.83 21.67 78.33 75.83 24.17 120
> mean 29.84 70.16 3.86 20.48 19 18.75 37.91 24.34 75.66 71.31 28.69 2694
> end data.
> exe.
> save outfile = "origdata.sav".
>
> select if CASE_LBL = "mean  ".
> rename var (var001 to var012 = m1 to m12).
> save outfile = "meanrow.sav" /keep m1 to m11.
>
> get file = "origdata.sav" /keep CASE_LBL var012.
> temp.
> select if CASE_LBL = "mean  ".
> save outfile = "grandmean.sav" /keep var012 /rename var012 = grandmean.
>
> get file = "origdata.sav" /keep CASE_LBL var012.
> select if CASE_LBL ne "mean  ".
> FLIP VARIABLES=var012  /NEWNAME=CASE_LBL  .
> ren var (@1.00 to @22.00 = marg1 to marg22).
> save outfile = "marginals.sav" /drop CASE_LBL  .
>
> get file = "meanrow.sav" .
> MATCH FILES /FILE=*
> /FILE="grandmean.sav" /FILE="marginals.sav" .
> EXECUTE.
>
> * end of data preparation.
> vector m = m1 to m11.
> vector marg = marg1 to marg22.
> vector prod (242).
> loop #i = 1 to 11.
> loop #j = 1 to 22.
>   compute prod(22 * (#i - 1) + #j) = m(#i) * marg(#j) / grandmean.
> end loop.
> end loop.
>
> exe.
>
>
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
> vlad simion
> Sent: Thursday, November 16, 2006 12:29 PM
> To: [hidden email]
> Subject: Problem with vectors
>
> Hi everybody,
> I have a data set that looks like this:
>
>   CASE_LBL var001 var002 var003 var004 var005 var006 var007 var008
> var009
> var010 var011 var012  @1.00    28 72 4.8 21.6 19.2 19.2 35.2 26.4 73.6
> 72 28
> 125  @2.00    29.51 70.49 2.46 21.31 19.67 18.03 38.52 23.77 76.23 69.67
> 30.33 122  @3.00    30.89 69.11 4.07 20.33 18.7 20.33 36.59 24.39 75.61
> 69.92 30.08 123  @4.00    28.33 71.67 2.5 19.17 19.17 21.67 37.5 21.67
> 78.33
> 70 30 120  @5.00    30.08 69.92 4.07 20.33 19.51 18.7 37.4 24.39 75.61
> 69.92
> 30.08 123  @6.00    29.51 70.49 3.28 21.31 19.67 18.03 37.7 24.59 75.41
> 71.31 28.69 122  @7.00    30 70 3.33 20.83 19.17 18.33 38.33 24.17 75.83
> 70.83 29.17 120  @8.00    32.5 67.5 4.17 21.67 15.83 18.33 40 25.83
> 74.17
> 74.17 25.83 120  @9.00    27.56 72.44 3.94 19.69 18.11 19.69 38.58 23.62
> 76.38 71.65 28.35 127  @10.00   29.75 70.25 4.13 20.66 19.01 19.01 37.19
> 24.79 75.21 70.25 29.75 121  @11.00   30.08 69.92 3.25 21.14 19.51 17.89
> 38.21 24.39 75.61 72.36 27.64 123  @12.00   30.08 69.92 4.07 21.14 18.7
> 18.7
> 37.4 25.2 74.8 69.92 30.08 123  @13.00   30.83 69.17 3.33 18.33 20 19.17
> 39.17 21.67 78.33 68.33 31.67 120  @14.00   28.69 71.31 4.1 20.49 18.85
> 18.03 38.52 24.59 75.41 72.95 27.05 122  @15.00   30.08 69.92 4.07 20.33
> 17.89 18.7 39.02 24.39 75.61 71.54 28.46 123  @16.00   30.89 69.11 4.07
> 21.14 18.7 18.7 37.4 25.2 74.8 69.92 30.08 123  @17.00   28.93 71.07
> 4.13
> 21.49 19.01 18.18 37.19 25.62 74.38 69.42 30.58 121  @18.00   32.06
> 67.94
> 3.82 20.61 20.61 17.56 37.4 24.43 75.57 70.23 29.77 131  @19.00   30.08
> 69.92 4.07 21.14 18.7 18.7 37.4 25.2 74.8 70.73 29.27 123  @20.00
> 28.33
> 71.67 4.17 19.17 19.17 19.17 38.33 23.33 76.67 73.33 26.67 120  @21.00
> 30.33 69.67 4.92 21.31 19.67 18.03 36.07 26.23 73.77 74.59 25.41 122
> @22.00
>    30 70 4.17 17.5 19.17 18.33 40.83 21.67 78.33 75.83 24.17 120  mean
> 29.84
> 70.16 3.86 20.48 19 18.75 37.91 24.34 75.66 71.31 28.69 2694 and I would
> like to have a vector of 242 elements (number @cases=11*number of
> variables=12) in which to store the following values:
> first element = 29.84*125/2694
> 2nd element = 29.84*122/2694
> 3rd element =  29.84*123/2694
> .............
> 11th element = 29.84*120/2694
> 12th element = 70.16*125/2694
> 13th element = 70.16*122/2694
> ............
> 22th element = 70.16*120/2694
> ...........
> 241th element = 28.69*122/2694
> 242th element = 28.69*120/2694
>
> does anyone have any suggestions?
>
> Many thanks.
>
> --
> Vlad Simion
> Data Analyst
> Tel:      +40 720130611
>



--
Vlad Simion
Data Analyst
Tel:      +40 720130611
Reply | Threaded
Open this post in threaded view
|

Re: Problem with vectors

Spousta Jan
In reply to this post by vlad simion
:-)

The problem is perhaps that you demanded a "vector" (=one-dimensional
structure) which I provided to you, but your matrix syntax indeed
computes a matrix (=two dimensional structire).

On this list, you very often get exactly what you demand.

Greetings

Jan

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
vlad simion
Sent: Thursday, November 16, 2006 4:46 PM
To: [hidden email]
Subject: Re: Problem with vectors

Hi Jan,

thanks for your reply.
sorry my mistake, I have indeed 22 cases.
I tried your code and it runs perfect with no errorrs or warnings, but
it does not give any figures for vector prod in the database.
anyway I manage to do this with matrix language.
here is the code, in case someone has any ideea how it can be optimized.

matrix.
get x /var= var001 var002 var003 var004 var005 var006 var007 var008
var009 var010 var011 var012.
compute y=make(ncol(x)-1,nrow(x)-1,0).
compute base=x(nrow(x),ncol(x)).
loop i=1 to 11.
loop j=1 to 22.
compute a=x(nrow(x),i).
compute d=x(j,ncol(x)).
compute y(i,j)=a*d/base.
end loop.
end loop.
print y.
end matrix.

many thanks once again
Cheers.

vlad.

On 11/16/06, Spousta Jan <[hidden email]> wrote:

>
> Hi Vlad,
>
> There seem to be some inconsistencies in your question, as 11 * 12 is
> 132 and not 242 and your data has 22 cases and not 11 cases. Since 22
> *
> 11 is equal to 242, I suppose that you think about 22 cases.
>
> My solution is not the most elegant one, but I tried to write it as
> clear as possible: Prepare the data, connect them in a simple way and
> use the common vector-loop trick.
>
> You can save the resulting variables prod1 to prod242 and merge them
> to the original file or whatever you wish.
>
> Greetings
>
> Jan
>
> data list free (" ", TAB) / CASE_LBL (a6) var001 (comma5.2)
> var002 (comma5.2) var003 (comma5.2) var004 (comma5.2) var005
> (comma5.2)
> var006 (comma5.2)
> var007 (comma5.2) var008 (comma5.2) var009 (comma5.2) var010
> (comma5.2)
> var011 (comma5.2)
> var012 (comma5.2) .
> begin data.
> @1.00 28 72 4.8 21.6 19.2 19.2 35.2 26.4 73.6 72 28 125 @2.00 29.51
> 70.49 2.46 21.31 19.67 18.03 38.52 23.77 76.23 69.67 30.33
> 122
> @3.00 30.89 69.11 4.07 20.33 18.7 20.33 36.59 24.39 75.61 69.92 30.08
> 123
> @4.00 28.33 71.67 2.5 19.17 19.17 21.67 37.5 21.67 78.33 70 30 120
> @5.00 30.08 69.92 4.07 20.33 19.51 18.7 37.4 24.39 75.61 69.92 30.08
> 123
>
> @6.00 29.51 70.49 3.28 21.31 19.67 18.03 37.7 24.59 75.41 71.31 28.69
> 122
> @7.00 30 70 3.33 20.83 19.17 18.33 38.33 24.17 75.83 70.83 29.17 120
> @8.00 32.5 67.5 4.17 21.67 15.83 18.33 40 25.83 74.17 74.17 25.83 120
> @9.00 27.56 72.44 3.94 19.69 18.11 19.69 38.58 23.62 76.38 71.65 28.35
> 127
> @10.00 29.75 70.25 4.13 20.66 19.01 19.01 37.19 24.79 75.21 70.25
> 29.75
> 121
> @11.00 30.08 69.92 3.25 21.14 19.51 17.89 38.21 24.39 75.61 72.36
> 27.64
> 123
> @12.00 30.08 69.92 4.07 21.14 18.7 18.7 37.4 25.2 74.8 69.92 30.08 123

> @13.00 30.83 69.17 3.33 18.33 20 19.17 39.17 21.67 78.33 68.33 31.67
> 120
>
> @14.00 28.69 71.31 4.1 20.49 18.85 18.03 38.52 24.59 75.41 72.95 27.05
> 122
> @15.00 30.08 69.92 4.07 20.33 17.89 18.7 39.02 24.39 75.61 71.54 28.46
> 123
> @16.00 30.89 69.11 4.07 21.14 18.7 18.7 37.4 25.2 74.8 69.92 30.08 123

> @17.00 28.93 71.07 4.13 21.49 19.01 18.18 37.19 25.62 74.38 69.42
> 30.58
> 121
> @18.00 32.06 67.94 3.82 20.61 20.61 17.56 37.4 24.43 75.57 70.23 29.77
> 131
> @19.00 30.08 69.92 4.07 21.14 18.7 18.7 37.4 25.2 74.8 70.73 29.27 123

> @20.00 28.33 71.67 4.17 19.17 19.17 19.17 38.33 23.33 76.67 73.33
> 26.67 120 @21.00 30.33 69.67 4.92 21.31 19.67 18.03 36.07 26.23 73.77
> 74.59 25.41
> 122
> @22.00 30 70 4.17 17.5 19.17 18.33 40.83 21.67 78.33 75.83 24.17 120
> mean 29.84 70.16 3.86 20.48 19 18.75 37.91 24.34 75.66 71.31 28.69
> 2694 end data.
> exe.
> save outfile = "origdata.sav".
>
> select if CASE_LBL = "mean  ".
> rename var (var001 to var012 = m1 to m12).
> save outfile = "meanrow.sav" /keep m1 to m11.
>
> get file = "origdata.sav" /keep CASE_LBL var012.
> temp.
> select if CASE_LBL = "mean  ".
> save outfile = "grandmean.sav" /keep var012 /rename var012 =
grandmean.

>
> get file = "origdata.sav" /keep CASE_LBL var012.
> select if CASE_LBL ne "mean  ".
> FLIP VARIABLES=var012  /NEWNAME=CASE_LBL  .
> ren var (@1.00 to @22.00 = marg1 to marg22).
> save outfile = "marginals.sav" /drop CASE_LBL  .
>
> get file = "meanrow.sav" .
> MATCH FILES /FILE=*
> /FILE="grandmean.sav" /FILE="marginals.sav" .
> EXECUTE.
>
> * end of data preparation.
> vector m = m1 to m11.
> vector marg = marg1 to marg22.
> vector prod (242).
> loop #i = 1 to 11.
> loop #j = 1 to 22.
>   compute prod(22 * (#i - 1) + #j) = m(#i) * marg(#j) / grandmean.
> end loop.
> end loop.
>
> exe.
>
>
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf
> Of vlad simion
> Sent: Thursday, November 16, 2006 12:29 PM
> To: [hidden email]
> Subject: Problem with vectors
>
> Hi everybody,
> I have a data set that looks like this:
>
>   CASE_LBL var001 var002 var003 var004 var005 var006 var007 var008
> var009
> var010 var011 var012  @1.00    28 72 4.8 21.6 19.2 19.2 35.2 26.4 73.6
> 72 28
> 125  @2.00    29.51 70.49 2.46 21.31 19.67 18.03 38.52 23.77 76.23
69.67
> 30.33 122  @3.00    30.89 69.11 4.07 20.33 18.7 20.33 36.59 24.39
75.61
> 69.92 30.08 123  @4.00    28.33 71.67 2.5 19.17 19.17 21.67 37.5 21.67
> 78.33
> 70 30 120  @5.00    30.08 69.92 4.07 20.33 19.51 18.7 37.4 24.39 75.61
> 69.92
> 30.08 123  @6.00    29.51 70.49 3.28 21.31 19.67 18.03 37.7 24.59
75.41
> 71.31 28.69 122  @7.00    30 70 3.33 20.83 19.17 18.33 38.33 24.17
75.83
> 70.83 29.17 120  @8.00    32.5 67.5 4.17 21.67 15.83 18.33 40 25.83
> 74.17
> 74.17 25.83 120  @9.00    27.56 72.44 3.94 19.69 18.11 19.69 38.58
23.62
> 76.38 71.65 28.35 127  @10.00   29.75 70.25 4.13 20.66 19.01 19.01
37.19
> 24.79 75.21 70.25 29.75 121  @11.00   30.08 69.92 3.25 21.14 19.51
17.89
> 38.21 24.39 75.61 72.36 27.64 123  @12.00   30.08 69.92 4.07 21.14
18.7
> 18.7
> 37.4 25.2 74.8 69.92 30.08 123  @13.00   30.83 69.17 3.33 18.33 20
19.17
> 39.17 21.67 78.33 68.33 31.67 120  @14.00   28.69 71.31 4.1 20.49
18.85
> 18.03 38.52 24.59 75.41 72.95 27.05 122  @15.00   30.08 69.92 4.07
20.33
> 17.89 18.7 39.02 24.39 75.61 71.54 28.46 123  @16.00   30.89 69.11
4.07
> 21.14 18.7 18.7 37.4 25.2 74.8 69.92 30.08 123  @17.00   28.93 71.07
> 4.13
> 21.49 19.01 18.18 37.19 25.62 74.38 69.42 30.58 121  @18.00   32.06
> 67.94
> 3.82 20.61 20.61 17.56 37.4 24.43 75.57 70.23 29.77 131  @19.00
30.08

> 69.92 4.07 21.14 18.7 18.7 37.4 25.2 74.8 70.73 29.27 123  @20.00
> 28.33
> 71.67 4.17 19.17 19.17 19.17 38.33 23.33 76.67 73.33 26.67 120  @21.00
> 30.33 69.67 4.92 21.31 19.67 18.03 36.07 26.23 73.77 74.59 25.41 122
> @22.00
>    30 70 4.17 17.5 19.17 18.33 40.83 21.67 78.33 75.83 24.17 120  mean
> 29.84
> 70.16 3.86 20.48 19 18.75 37.91 24.34 75.66 71.31 28.69 2694 and I
> would like to have a vector of 242 elements (number @cases=11*number
> of
> variables=12) in which to store the following values:
> first element = 29.84*125/2694
> 2nd element = 29.84*122/2694
> 3rd element =  29.84*123/2694
> .............
> 11th element = 29.84*120/2694
> 12th element = 70.16*125/2694
> 13th element = 70.16*122/2694
> ............
> 22th element = 70.16*120/2694
> ...........
> 241th element = 28.69*122/2694
> 242th element = 28.69*120/2694
>
> does anyone have any suggestions?
>
> Many thanks.
>
> --
> Vlad Simion
> Data Analyst
> Tel:      +40 720130611
>



--
Vlad Simion
Data Analyst
Tel:      +40 720130611