Is it possible to guess if I have selected 0 records?

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

Is it possible to guess if I have selected 0 records?

Boika Mileva
Dear colleagues!

I am developing a Data Checking syntax, in which I put the value 1 in
control variables if a corresponding condition is not kept. Then I select
the records, which have 1 in the corresponding control varible and issue a
list of the wrong records. Is it possible to have some indication about
the number of selected records, especialy in cases when this number is 0?

I would be grateful if some of you helps me with this problem!

Thank you in advance!

With best wishes!

Boika
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to guess if I have selected 0 records?

xiaoqin.wan@gmail.com
Hi,

if you use SPSS 14 and up, you can try this:

BEGIN PROGRAM
import spss
if spss.GetCaseCount() == 0:
 spss.Submit("TITLE *File is empty")
END PROGRAM.

HTH

Baiyun

2007/10/11, Boika Mileva <[hidden email]>:

>
> Dear colleagues!
>
> I am developing a Data Checking syntax, in which I put the value 1 in
> control variables if a corresponding condition is not kept. Then I select
> the records, which have 1 in the corresponding control varible and issue a
> list of the wrong records. Is it possible to have some indication about
> the number of selected records, especialy in cases when this number is 0?
>
> I would be grateful if some of you helps me with this problem!
>
> Thank you in advance!
>
> With best wishes!
>
> Boika
>
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to guess if I have selected 0 records?

Boika Mileva
In reply to this post by Boika Mileva
Thank you very much, Baiyun! Your code seems wonderful, but unfortunately,
I use SPSS 13!... Actually I found a way to compute the number of cases
where there is an error, using agregation:

COMPUTE ONE=1.
EXECUTE.

USE ALL.
COMPUTE filter_$=(Err_MissQuest=1).

AGGREGATE
  /OUTFILE=!Path+'AGGR.SAV'
  /BREAK=ONE
  /nbcases = SUM(filter_$).

MATCH FILES /FILE=*
 /TABLE=!Path+'AGGR.SAV'
 /BY ONE.
EXECUTE.

USE ALL.
FILTER BY filter_$.
EXECUTE .

This way in the variable nbcases I have 0 if there are no errors, or
nbcases>0 if there are records with errors. But now I HAVE ANOTHER
PROBLEM - With the DO IF Command. When I write:

SORT CASES BY
  nbcases (D) .

DO IF $casenum=1 and nbcases > 0.
list num week tsb trim.
ELSE.
ECHO "There are no errors".
END IF.
EXE.

I have to get a list of 2 records, because I have 2 wrong records
(nbcases=2), but instead I get an error message:

>Error # 4095.  Command name: list
>The transformations program contains an unclosed LOOP, DO IF, or complex
>file structure.  Use the level-of-control shown to the left of the SPSS
>commands to determine the range of LOOPs and DO IFs.
>This command not executed.

and at the OUTPUT window I have

"There are no errors"

displayed - the instruction after the ELSE STATEMENT... ?

I would be grateful if you have any suggestions!

With best wishes:

Boika
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to guess if I have selected 0 records?

Raynald Levesque-2
Hi

Since python is not available in v13, see the second example of
http://www.spsstools.net/SampleSyntax.htm#SelfAdjustingSyntax
for an alternative (more complex and less user friendly) solution.

Regards

--
Raynald Levesque
www.spsstools.net

On 10/11/07, Boika Mileva <[hidden email]> wrote:

>
> Thank you very much, Baiyun! Your code seems wonderful, but unfortunately,
> I use SPSS 13!... Actually I found a way to compute the number of cases
> where there is an error, using agregation:
>
> COMPUTE ONE=1.
> EXECUTE.
>
> USE ALL.
> COMPUTE filter_$=(Err_MissQuest=1).
>
> AGGREGATE
>   /OUTFILE=!Path+'AGGR.SAV'
>   /BREAK=ONE
>   /nbcases = SUM(filter_$).
>
> MATCH FILES /FILE=*
> /TABLE=!Path+'AGGR.SAV'
> /BY ONE.
> EXECUTE.
>
> USE ALL.
> FILTER BY filter_$.
> EXECUTE .
>
> This way in the variable nbcases I have 0 if there are no errors, or
> nbcases>0 if there are records with errors. But now I HAVE ANOTHER
> PROBLEM - With the DO IF Command. When I write:
>
> SORT CASES BY
>   nbcases (D) .
>
> DO IF $casenum=1 and nbcases > 0.
> list num week tsb trim.
> ELSE.
> ECHO "There are no errors".
> END IF.
> EXE.
>
> I have to get a list of 2 records, because I have 2 wrong records
> (nbcases=2), but instead I get an error message:
>
> >Error # 4095.  Command name: list
> >The transformations program contains an unclosed LOOP, DO IF, or complex
> >file structure.  Use the level-of-control shown to the left of the SPSS
> >commands to determine the range of LOOPs and DO IFs.
> >This command not executed.
>
> and at the OUTPUT window I have
>
> "There are no errors"
>
> displayed - the instruction after the ELSE STATEMENT... ?
>
> I would be grateful if you have any suggestions!
>
> With best wishes:
>
> Boika
>