COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### SPSS commands for making some computations

• Email
• 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

See related articles to this posting

```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
"When all else fails, RTFM."
```
 0
Reply Bruce 11/11/2009 3:19:16 PM

1 Replies
382 Views

Similar Articles

11/30/2013 7:05:02 AM
page loaded in 4076 ms. (0)