SPSS commands for making some computations

  • Follow


Hi all,

I have an SPSS datafile. I want to get the number of cases that take
the value 1 for one variable and the value 2 for the other variable .
Afterwards i need to divide the result "the number of cases satisfying
both conditions" by the total number of cases taking the value 1 in
variable 1. I want to get the final result "the proportion" written to
an SPSS datafile and I want all this to be performed using the SPSS
commands.

Is this possible,
Really need your help,
A.A.A
0
Reply ayafeps (6) 11/11/2009 12:43:39 PM

On Nov 11, 7:43=A0am, "A.A.A" <ayaf...@yahoo.com> wrote:
> Hi all,
>
> I have an SPSS datafile. I want to get the number of cases that take
> the value 1 for one variable and the value 2 for the other variable .
> Afterwards i need to divide the result "the number of cases satisfying
> both conditions" by the total number of cases taking the value 1 in
> variable 1. I want to get the final result "the proportion" written to
> an SPSS datafile and I want all this to be performed using the SPSS
> commands.
>
> Is this possible,
> Really need your help,
> A.A.A

new file.
dataset close all.

data list list / v1 v2 (2f2.0).
begin data
1 2
1 1
2 2
1 2
3 4
5 4
end data.

compute v1eq1 =3D (v1 EQ 1).
compute v2eq2 =3D (v2 EQ 2).
compute both =3D v1eq1 and v2eq2.
compute nobreak =3D 1.
exe.

aggregate outfile =3D * mode =3D addvariables /
 break =3D nobreak /
 v1count =3D sum(v1eq1) /
 bothcount =3D sum(both) .

compute prop =3D bothcount / v1count.
format prop (f5.3).

temporary.
select if $casenum EQ 1.
list v1count to prop.

--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/Home
"When all else fails, RTFM."
0
Reply Bruce 11/11/2009 3:19:16 PM


1 Replies
333 Views

(page loaded in 0.055 seconds)

Similiar Articles:













7/22/2012 4:41:26 PM


Reply: