how to check if file has no cases?

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

how to check if file has no cases?

Ali Korkmaz
Hi,

I am doing a huge loop and in this loop I'm doing lots of selections and in
some of these selections, there are no cases left in the data file (data
file is empty with variables).  I want to skip these situations by checking
if there is any case in the file, if not I want to just go next loop.

I have a unique identifier in my data file. I tried using several options
and none of them worked so far.

Thanks for feedback,
--Ali

Some of the options I tried:

- Do if not(sysmis(id))


 - !if (id !NE !NULL) !then

=====================
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: how to check if file has no cases?

Lemon, John S.
Untested - but try using the $CASENUM variable which records the case number - this may help.

Best Wishes

John S. Lemon

DIT - Student Liaison Officer
University of Aberdeen
Edward Wright Building: Room G51
Tel:  +44 1224 273350
Fax: +44 1224 273372


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ali Korkmaz
Sent: 05 March 2008 21:07
To: [hidden email]
Subject: how to check if file has no cases?

Hi,

I am doing a huge loop and in this loop I'm doing lots of selections and in
some of these selections, there are no cases left in the data file (data
file is empty with variables).  I want to skip these situations by checking
if there is any case in the file, if not I want to just go next loop.

I have a unique identifier in my data file. I tried using several options
and none of them worked so far.

Thanks for feedback,
--Ali

Some of the options I tried:

- Do if not(sysmis(id))


 - !if (id !NE !NULL) !then

=====================
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


The University of Aberdeen is a charity registered in Scotland, No SC013683.

=====================
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: how to check if file has no cases?

Ali Korkmaz
Sorry, I forgot to mention that one.  I used it but since there is no case,
$casenum didn't work either.

Thanks,
--Ali

On Wed, Mar 5, 2008 at 4:12 PM, Lemon, John S. <[hidden email]> wrote:

> Untested - but try using the $CASENUM variable which records the case
> number - this may help.
>
> Best Wishes
>
> John S. Lemon
>
> DIT - Student Liaison Officer
> University of Aberdeen
> Edward Wright Building: Room G51
> Tel:  +44 1224 273350
> Fax: +44 1224 273372
>
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
> Ali Korkmaz
> Sent: 05 March 2008 21:07
> To: [hidden email]
> Subject: how to check if file has no cases?
>
> Hi,
>
> I am doing a huge loop and in this loop I'm doing lots of selections and
> in
> some of these selections, there are no cases left in the data file (data
> file is empty with variables).  I want to skip these situations by
> checking
> if there is any case in the file, if not I want to just go next loop.
>
> I have a unique identifier in my data file. I tried using several options
> and none of them worked so far.
>
> Thanks for feedback,
> --Ali
>
> Some of the options I tried:
>
> - Do if not(sysmis(id))
>
>
>  - !if (id !NE !NULL) !then
>
> =====================
> 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
>
>
> The University of Aberdeen is a charity registered in Scotland, No
> SC013683.
>

=====================
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: how to check if file has no cases?

Albert-Jan Roskam
Hi,

It might be best to do everything in Python, but
here's a hybrid approach:

begin program.
import spss
spss.SetMacroValue("!cnt",spss.GetCaseCount())
spss.Submit("display macros.")
end program.

and then you can put something like this in your
macro:

!if !cnt = 0 !then
* do nothing.

!else
* continue loop.

!ifend.


Note that spss.GetCaseCount reads the number of files
from header info, so this might only be updated after
a data pass (exe).

Cheers!!
Albert-Jan


--- Ali Korkmaz <[hidden email]> wrote:

> Sorry, I forgot to mention that one.  I used it but
> since there is no case,
> $casenum didn't work either.
>
> Thanks,
> --Ali
>
> On Wed, Mar 5, 2008 at 4:12 PM, Lemon, John S.
> <[hidden email]> wrote:
>
> > Untested - but try using the $CASENUM variable
> which records the case
> > number - this may help.
> >
> > Best Wishes
> >
> > John S. Lemon
> >
> > DIT - Student Liaison Officer
> > University of Aberdeen
> > Edward Wright Building: Room G51
> > Tel:  +44 1224 273350
> > Fax: +44 1224 273372
> >
> >
> > -----Original Message-----
> > From: SPSSX(r) Discussion
> [mailto:[hidden email]] On Behalf Of
> > Ali Korkmaz
> > Sent: 05 March 2008 21:07
> > To: [hidden email]
> > Subject: how to check if file has no cases?
> >
> > Hi,
> >
> > I am doing a huge loop and in this loop I'm doing
> lots of selections and
> > in
> > some of these selections, there are no cases left
> in the data file (data
> > file is empty with variables).  I want to skip
> these situations by
> > checking
> > if there is any case in the file, if not I want to
> just go next loop.
> >
> > I have a unique identifier in my data file. I
> tried using several options
> > and none of them worked so far.
> >
> > Thanks for feedback,
> > --Ali
> >
> > Some of the options I tried:
> >
> > - Do if not(sysmis(id))
> >
> >
> >  - !if (id !NE !NULL) !then
> >
> > =====================
> > 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
> >
> >
> > The University of Aberdeen is a charity registered
> in Scotland, No
> > SC013683.
> >
>
> =====================
> 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
>



      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page.
http://www.yahoo.com/r/hs

=====================
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