|
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 |
|
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 > |
|
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 |
|
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 > |
| Free forum by Nabble | Edit this page |
