Questions Select IF

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

Questions Select IF

Javier Meneses
Hi , I have use command Select If like that in 1) and run frequencies jefe. The outcome was , 

1) SELECT IF jefe=1.
    SELECT IF ipcf>0.
    EXECUTE. 

Frecuencies
=1 si jefe 
N Válido 121517
Perdidos 0


But I run like 2) the outcome is other.

SELECT IF jefe=1.
EXECUTE.
SELECT IF ipcf>0.
EXECUTE. 

Frecuencies
=1 si jefe 
N Válido 126144
Perdidos 0

Why is there this different in N?


      Javier (excume my bad English)

===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: Questions Select IF

Bruce Weaver
Administrator
Hello Javier--hola.  I cannot duplicate your problem.  The syntax pasted below uses both sets of syntax you posted plus a third more efficient method, and all 3 yield exactly the same results.  In every case, I get a frequency count = 221:

jefe
                Freq  Percent     Valid %    Cumulative %
Valid 1     221   100.0       100.0        100.0


What do you get when you run the following syntax?


********* The syntax *************.
* Save any datasets that you want to save before running this syntax.
* Generate a dataset containing variables jefe and ipcf.

NEW FILE.
DATASET CLOSE all.

INPUT PROGRAM.
LOOP Case = 1 to 1000.
END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.
EXECUTE.

SET RNG = MT MTINDEX = 20160420.

COMPUTE jefe = rnd(rv.uniform(0,1)).
COMPUTE ipcf = rv.normal(0,1).
FORMATS jefe(F1).
FREQUENCIES jefe.
DESCRIPTIVES ipcf.

DATASET NAME d1.
* Make two copies of the data.
DATASET COPY d2.
DATASET COPY d3.

* Javier's first method using dataset d1.
DATASET ACTIVATE d1.
SELECT IF jefe=1.
SELECT IF ipcf>0.
EXECUTE.
FREQUENCIES jefe.

* Javier's second method using dataset d2.
DATASET ACTIVATE d2.
SELECT IF jefe=1.
EXECUTE.
SELECT IF ipcf>0.
EXECUTE.
FREQUENCIES jefe.

* A third method using dataset d3.
DATASET ACTIVATE d3.
SELECT IF (jefe EQ 1) and (ipcf GT 0).
FREQUENCIES jefe.

* Un-comment and run the next two lines to close the open datasets.
*NEW FILE.
*DATASET CLOSE ALL.

********* End of syntax *************.


Javier Meneses wrote
Hi , I have use command Select If like that in 1) and run frequencies jefe.
The outcome was ,

1) SELECT IF jefe=1.
    SELECT IF ipcf>0.
    EXECUTE.

*Frecuencies*
=1 si jefe
N Válido 121517
Perdidos 0


But I run like 2) the outcome is other.

SELECT IF jefe=1.
EXECUTE.
SELECT IF ipcf>0.
EXECUTE.

*Frecuencies*
=1 si jefe
N Válido 126144
Perdidos 0

Why is there this different in *N*?


      Javier (excume my bad English)

=====================
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
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Questions Select IF

Art Kendall
In reply to this post by Javier Meneses
Please create a small set of syntax something similar to that below that demonstrates the problem.


data list list/id (n2) jefe (f1) ipcf (f3).
begin data
1 1 -1
2 1 0
3 1 1
4 0 -1
5 0 0
6 0 1
end data.
dataset name complete1.
dataset copy complete2.
dataset copy complete3.
title first try.
dataset activate complete1.
crosstabs tables = jefe by ipcf.
temporary.
select if jefe eq 1 and ipcf gt 0.
frequencies variables = id.
title second try.
dataset activate complete2.
temporary.
select if jefe eq 1.
select if ipcf gt 0.
frequencies variables = id.
title third try.
dataset activate complete3.
select if jefe eq 1.
frequencies variables = id.
select if ipcf gt 0.
frequencies variables = id.
Art Kendall
Social Research Consultants