How to determine the number of cases within data

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

How to determine the number of cases within data

albert_sun
hi,

Given a data, is there a way of using syntax to determine the number of cases contained in it? The case scenario I want to use is that if size > A, go syntax A. If size <A, go syntax B.

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: How to determine the number of cases within data

Albert-Jan Roskam
hi,
 
Untested:
 
* this goes at the beginning of your code.
file handle syntax_a /name = "c:/temp/measly_n.sps".
file handle syntax_b /name = "c:/temp/large_n.sps".
define !cutoffValue () 1000 !enddefine.
datafile attribute attribute = cutoffValue(!cutoffValue).
 
* put this where it's needed.
begin program.
import spss, spssaux
nCases, cutoffValue = spss.GetCaseCount(), spssaux.getAttributesDict()["cutoffValue"]
spss.Submit("insert file = 'syntax_a'." if nCases < cutoffValue else "insert file = 'syntax_b'.")
end program.
 
if (!nCases lt !cutoffValue)
Regards,
Albert-Jan


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a
fresh water system, and public health, what have the Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

From: albert_sun <[hidden email]>
To: [hidden email]
Sent: Friday, July 26, 2013 6:40 AM
Subject: [SPSSX-L] How to determine the number of cases within data

hi,

Given a data, is there a way of using syntax to determine the number of
cases contained in it? The case scenario I want to use is that if size > A,
go syntax A. If size <A, go syntax B.

Thanks



--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/How-to-determine-the-number-of-cases-within-data-tp5721378.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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 determine the number of cases within data

Jon K Peck
In reply to this post by albert_sun
This would require the use of Python programmability unless you use some very convoluted workarounds.

Something like this.
begin program.
spss.Submit("dataset activate a")
casecountA = spss.GetCaseCount()
spss.Submit("dataset activate b")
casecountB = spss.GetCaseCount()

if casecountA > casecountB:
    spss.Submit(<one set of syntax>)
else:
    spss.Submit(<the other set>)
end program.

Note that the case count is not always known if the data do not come from a sav file and the data have not been previously passed.




Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        albert_sun <[hidden email]>
To:        [hidden email],
Date:        07/25/2013 10:40 PM
Subject:        [SPSSX-L] How to determine the number of cases within data
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




hi,

Given a data, is there a way of using syntax to determine the number of
cases contained in it? The case scenario I want to use is that if size > A,
go syntax A. If size <A, go syntax B.

Thanks



--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/How-to-determine-the-number-of-cases-within-data-tp5721378.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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 determine the number of cases within data

Art Kendall
I read the OP differently. Although I don't know what is wanted if size = A. A is hard coded in the syntax
this is untested
get file...
aggregate .../mode=addvariables /size = n.
compute A = 1234.
do if size gt A.
...
else if size lt A.
...
else.
print /'oops  cannot pick syntax set'/.
end if.

However, I wonder why the OP wants to do this.
Art Kendall
Social Research Consultants
On 7/26/2013 8:28 AM, Jon K Peck [via SPSSX Discussion] wrote:
This would require the use of Python programmability unless you use some very convoluted workarounds.

Something like this.
begin program.
spss.Submit("dataset activate a")
casecountA = spss.GetCaseCount()
spss.Submit("dataset activate b")
casecountB = spss.GetCaseCount()

if casecountA > casecountB:
    spss.Submit(<one set of syntax>)
else:
    spss.Submit(<the other set>)
end program.

Note that the case count is not always known if the data do not come from a sav file and the data have not been previously passed.




Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        albert_sun <[hidden email]>
To:        [hidden email],
Date:        07/25/2013 10:40 PM
Subject:        [SPSSX-L] How to determine the number of cases within data
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




hi,

Given a data, is there a way of using syntax to determine the number of
cases contained in it? The case scenario I want to use is that if size > A,
go syntax A. If size <A, go syntax B.

Thanks



--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/How-to-determine-the-number-of-cases-within-data-tp5721378.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

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





If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/How-to-determine-the-number-of-cases-within-data-tp5721378p5721383.html
To start a new topic under SPSSX Discussion, email [hidden email]
To unsubscribe from SPSSX Discussion, click here.
NAML

Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: How to determine the number of cases within data

Jon K Peck
If there is just one dataset and the syntax run would be conditional on the number of cases, AGGREGATE could calculate the size, but the do if is a case loop and you would be limited to running transformations within the conditional.  The programmability solution, which would work for any syntax, would be

begin program.
import spss
size = spss.GetCaseCount()
if size > 1234:
    spss.Submit(<some syntax>)
else:
    spss.Submit(<some other syntax>)
end program.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        Art Kendall <[hidden email]>
To:        [hidden email],
Date:        07/26/2013 07:11 AM
Subject:        Re: [SPSSX-L] How to determine the number of cases within data
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




I read the OP differently. Although I don't know what is wanted if size = A. A is hard coded in the syntax
this is untested
get file...
aggregate .../mode=addvariables /size = n.
compute A = 1234.
do if size gt A.
...
else if size lt A.
...
else.
print /'oops  cannot pick syntax set'/.
end if.

However, I wonder why the OP wants to do this.

Art Kendall
Social Research Consultants

On 7/26/2013 8:28 AM, Jon K Peck [via SPSSX Discussion] wrote:
This would require the use of Python programmability unless you use some very convoluted workarounds.

Something like this.

begin program.

spss.Submit("dataset activate a")

casecountA = spss.GetCaseCount()

spss.Submit("dataset activate b")

casecountB = spss.GetCaseCount()


if casecountA > casecountB:

   spss.Submit(<one set of syntax>)

else:

   spss.Submit(<the other set>)

end program.


Note that the case count is not always known if the data do not come from a sav file and the data have not been previously passed.





Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM

[hidden email]
phone: 720-342-5621





From:        
albert_sun <[hidden email]>
To:        
[hidden email],
Date:        
07/25/2013 10:40 PM
Subject:        
[SPSSX-L] How to determine the number of cases within data
Sent by:        
"SPSSX(r) Discussion" <[hidden email]>




hi,

Given a data, is there a way of using syntax to determine the number of
cases contained in it? The case scenario I want to use is that if size > A,
go syntax A. If size <A, go syntax B.

Thanks



--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/How-to-determine-the-number-of-cases-within-data-tp5721378.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

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






If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/How-to-determine-the-number-of-cases-within-data-tp5721378p5721383.html
To start a new topic under SPSSX Discussion, email [hidden email]
To unsubscribe from SPSSX Discussion,
click here.
NAML

Art Kendall
Social Research Consultants



View this message in context: Re: How to determine the number of cases within data
Sent from the
SPSSX Discussion mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: How to determine the number of cases within data

Art Kendall
The programmability solution would be more machine efficient. 
The inefficiency of the aggregate method would only be a concern in unusually large files.

I still wonder why the OP wants to do this.  Does it have to do with having at least 30 cases?
Art Kendall
Social Research Consultants
On 7/26/2013 9:24 AM, Jon K Peck wrote:
If there is just one dataset and the syntax run would be conditional on the number of cases, AGGREGATE could calculate the size, but the do if is a case loop and you would be limited to running transformations within the conditional.  The programmability solution, which would work for any syntax, would be

begin program.
import spss
size = spss.GetCaseCount()
if size > 1234:
    spss.Submit(<some syntax>)
else:
    spss.Submit(<some other syntax>)
end program.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        Art Kendall [hidden email]
To:        [hidden email],
Date:        07/26/2013 07:11 AM
Subject:        Re: [SPSSX-L] How to determine the number of cases within data
Sent by:        "SPSSX(r) Discussion" [hidden email]




I read the OP differently. Although I don't know what is wanted if size = A. A is hard coded in the syntax
this is untested
get file...
aggregate .../mode=addvariables /size = n.
compute A = 1234.
do if size gt A.
...
else if size lt A.
...
else.
print /'oops  cannot pick syntax set'/.
end if.

However, I wonder why the OP wants to do this.

Art Kendall
Social Research Consultants

On 7/26/2013 8:28 AM, Jon K Peck [via SPSSX Discussion] wrote:
This would require the use of Python programmability unless you use some very convoluted workarounds.

Something like this.

begin program.

spss.Submit("dataset activate a")

casecountA = spss.GetCaseCount()

spss.Submit("dataset activate b")

casecountB = spss.GetCaseCount()


if casecountA > casecountB:

   spss.Submit(<one set of syntax>)

else:

   spss.Submit(<the other set>)

end program.


Note that the case count is not always known if the data do not come from a sav file and the data have not been previously passed.





Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM

[hidden email]
phone: 720-342-5621





From:        
albert_sun <[hidden email]>
To:        
[hidden email],
Date:        
07/25/2013 10:40 PM
Subject:        
[SPSSX-L] How to determine the number of cases within data
Sent by:        
"SPSSX(r) Discussion" <[hidden email]>




hi,

Given a data, is there a way of using syntax to determine the number of
cases contained in it? The case scenario I want to use is that if size > A,
go syntax A. If size <A, go syntax B.

Thanks



--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/How-to-determine-the-number-of-cases-within-data-tp5721378.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

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






If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/How-to-determine-the-number-of-cases-within-data-tp5721378p5721383.html
To start a new topic under SPSSX Discussion, email [hidden email]
To unsubscribe from SPSSX Discussion,
click here.
NAML

Art Kendall
Social Research Consultants



View this message in context: Re: How to determine the number of cases within data
Sent from the
SPSSX Discussion mailing list archive at Nabble.com.

===================== 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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: How to determine the number of cases within data

David Marso
Administrator
In reply to this post by Art Kendall
This would only work if "..." contains ONLY transformation commands ;-(

Art Kendall wrote
I read the OP differently. Although I don't know what is wanted if size =
          A. A is hard coded in the syntax
            this is untested
          get file...
            aggregate
              .../mode=addvariables /size = n.
                compute A = 1234.
                do if size gt A.
                  ...
                      else if size lt A.
                        ...
                          else.
                            print /'oops  cannot pick
                              syntax set'/.
                          end
                if.
               
                However, I wonder why
                    the OP wants to do this.
             
      Art Kendall
Social Research Consultants
      On 7/26/2013 8:28 AM, Jon K Peck [via SPSSX Discussion] wrote:
   
     This would require
        the use of Python programmability
        unless you use some very convoluted workarounds.
     
     
      Something like this.
     
      begin program.
     
      spss.Submit("dataset activate a")
     
      casecountA = spss.GetCaseCount()
     
      spss.Submit("dataset activate b")
     
      casecountB = spss.GetCaseCount()
     
     
      if casecountA > casecountB:
     
          spss.Submit(<one set
        of syntax>)
     
      else:
     
          spss.Submit(<the other
        set>)
     
      end program.
     
     
      Note that the case count is not
        always
        known if the data do not come from a sav file and the data have
        not been
        previously passed.
     
     
     
     
       
        Jon Peck (no "h") aka Kim
        Senior Software Engineer, IBM
        [hidden email]
        phone: 720-342-5621
     
     
     
     
     
      From:      
         albert_sun < [hidden email] >
     
      To:      
          [hidden email] ,
     
     
      Date:      
         07/25/2013 10:40 PM
     
      Subject:    
           [SPSSX-L] How
        to determine the number of cases within data
     
      Sent by:    
           "SPSSX(r)
        Discussion" < [hidden email] >
     
     
     
     
     
      hi,
         
          Given a data, is there a way of using syntax to determine the
          number of
          cases contained in it? The case scenario I want to use is that
          if size
          > A,
          go syntax A. If size <A, go syntax B.
         
          Thanks
         
         
         
          --
          View this message in context: http://spssx-discussion.1045642.n5.nabble.com/How-to-determine-the-number-of-cases-within-data-tp5721378.html 
          Sent from the SPSSX Discussion mailing list archive at
          Nabble.com.
         
          =====================
          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
         
       
     
     
     
     
     
        If you reply to this email, your
          message will be added to the discussion below:
        http://spssx-discussion.1045642.n5.nabble.com/How-to-determine-the-number-of-cases-within-data-tp5721378p5721383.html 
     
     
        To start a new topic under SPSSX Discussion, email
        [hidden email] 
        To unsubscribe from SPSSX Discussion, click
          here .
        NAML
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: How to determine the number of cases within data

Bruce Weaver
Administrator
David's ginger-haired bastard "horrible hack" method would work.  (That's probably one of the approaches Jon was thinking about when he mentioned "very convoluted workarounds".)  I will admit that it has the disadvantage of requiring only native SPSS syntax.  :-|

The following is untested, but close to what you would need, I think.  (I assumed that for the second condition, you really wanted Size less than or equal to A, not just Size < A.)

* Compute Size with AGGREGATE as in Art's example.
DO IF Size GT A.
- WRITE OUTFILE = "C:\Temp\InsertCommand.sps" / "INSERT FILE = 'C:\MyFolder\SyntaxA.SPS'." .
ELSE IF Size LE A.
- WRITE OUTFILE = "C:\Temp\InsertCommand.sps" / "INSERT FILE = 'C:\MyFolder\SyntaxB.SPS'." .
END IF.
EXECUTE.
INSERT FILE = "C:\Temp\InsertCommand.sps".
ERASE FILE =  "C:\Temp\InsertCommand.sps".

The files SyntaxA.SPS and SyntaxB.SPS hold the two different versions of the syntax, of course.

Donning flame-proof suit & ducking for cover!  ;-)


David Marso wrote
This would only work if "..." contains ONLY transformation commands ;-(

Art Kendall wrote
I read the OP differently. Although I don't know what is wanted if size =
          A. A is hard coded in the syntax
            this is untested
          get file...
            aggregate
              .../mode=addvariables /size = n.
                compute A = 1234.
                do if size gt A.
                  ...
                      else if size lt A.
                        ...
                          else.
                            print /'oops  cannot pick
                              syntax set'/.
                          end
                if.
               
                However, I wonder why
                    the OP wants to do this.
             
      Art Kendall
Social Research Consultants
      On 7/26/2013 8:28 AM, Jon K Peck [via SPSSX Discussion] wrote:
   
     This would require
        the use of Python programmability
        unless you use some very convoluted workarounds.
     
     
      Something like this.
     
      begin program.
     
      spss.Submit("dataset activate a")
     
      casecountA = spss.GetCaseCount()
     
      spss.Submit("dataset activate b")
     
      casecountB = spss.GetCaseCount()
     
     
      if casecountA > casecountB:
     
          spss.Submit(<one set
        of syntax>)
     
      else:
     
          spss.Submit(<the other
        set>)
     
      end program.
     
     
      Note that the case count is not
        always
        known if the data do not come from a sav file and the data have
        not been
        previously passed.
     
     
     
     
       
        Jon Peck (no "h") aka Kim
        Senior Software Engineer, IBM
        [hidden email]
        phone: 720-342-5621
     
     
     
     
     
      From:      
         albert_sun < [hidden email] >
     
      To:      
          [hidden email] ,
     
     
      Date:      
         07/25/2013 10:40 PM
     
      Subject:    
           [SPSSX-L] How
        to determine the number of cases within data
     
      Sent by:    
           "SPSSX(r)
        Discussion" < [hidden email] >
     
     
     
     
     
      hi,
         
          Given a data, is there a way of using syntax to determine the
          number of
          cases contained in it? The case scenario I want to use is that
          if size
          > A,
          go syntax A. If size <A, go syntax B.
         
          Thanks
         
         
         
          --
          View this message in context: http://spssx-discussion.1045642.n5.nabble.com/How-to-determine-the-number-of-cases-within-data-tp5721378.html 
          Sent from the SPSSX Discussion mailing list archive at
          Nabble.com.
         
          =====================
          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
         
       
     
     
     
     
     
        If you reply to this email, your
          message will be added to the discussion below:
        http://spssx-discussion.1045642.n5.nabble.com/How-to-determine-the-number-of-cases-within-data-tp5721378p5721383.html 
     
     
        To start a new topic under SPSSX Discussion, email
        [hidden email] 
        To unsubscribe from SPSSX Discussion, click
          here .
        NAML
--
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: How to determine the number of cases within data

David Marso
Administrator
Art's ex used MODE ADDVARIABLES ;-(
You would want to protect the DO IF blah blah with an outer
DO IF $CASENUM=1.
...
END IF.

-or-
AGGREGATE to an external DATASET.  Activate it.  Do the WRITE...
ACTIVATE the main data file of interest.
INSERT the file created from DMGHBHH .

-or-
Create a macro containing the two different syntax variants which accepts a positional argument.
DEFINE AorB (!POS !CMDEND).
....
!IF (!1 !EQ A) !THEN
....
code for syntax< criteria
!ELSE
 code for syntax >= criteria
!IFEND
!ENDDEFINE.

aggregate as before to external dataset.
DATASET DECLARE agg .
AGGREGATE OUTFILE agg / size=N.
DATASET ACTIVATE agg .
DO IF (size LT criteria).
WRITE OUTFILE blah / "AorB A".
ELSE.
WRITE OUTFILE blah / "AorB B".
END IF.
DATASET ACTIVATE rawdataofinterest.
INCLUDE blah .
ERASE FILE=blah.
DATASET CLOSE agg.

Bruce Weaver wrote
David's ginger-haired bastard "horrible hack" method would work.  (That's probably one of the approaches Jon was thinking about when he mentioned "very convoluted workarounds".)  I will admit that it has the disadvantage of requiring only native SPSS syntax.  :-|

The following is untested, but close to what you would need, I think.  (I assumed that for the second condition, you really wanted Size less than or equal to A, not just Size < A.)

* Compute Size with AGGREGATE as in Art's example.
DO IF Size GT A.
- WRITE OUTFILE = "C:\Temp\InsertCommand.sps" / "INSERT FILE = 'C:\MyFolder\SyntaxA.SPS'." .
ELSE IF Size LE A.
- WRITE OUTFILE = "C:\Temp\InsertCommand.sps" / "INSERT FILE = 'C:\MyFolder\SyntaxB.SPS'." .
END IF.
EXECUTE.
INSERT FILE = "C:\Temp\InsertCommand.sps".
ERASE FILE =  "C:\Temp\InsertCommand.sps".

The files SyntaxA.SPS and SyntaxB.SPS hold the two different versions of the syntax, of course.

Donning flame-proof suit & ducking for cover!  ;-)


David Marso wrote
This would only work if "..." contains ONLY transformation commands ;-(

Art Kendall wrote
I read the OP differently. Although I don't know what is wanted if size =
          A. A is hard coded in the syntax
            this is untested
          get file...
            aggregate
              .../mode=addvariables /size = n.
                compute A = 1234.
                do if size gt A.
                  ...
                      else if size lt A.
                        ...
                          else.
                            print /'oops  cannot pick
                              syntax set'/.
                          end
                if.
               
                However, I wonder why
                    the OP wants to do this.
             
      Art Kendall
Social Research Consultants
      On 7/26/2013 8:28 AM, Jon K Peck [via SPSSX Discussion] wrote:
   
     This would require
        the use of Python programmability
        unless you use some very convoluted workarounds.
     
     
      Something like this.
     
      begin program.
     
      spss.Submit("dataset activate a")
     
      casecountA = spss.GetCaseCount()
     
      spss.Submit("dataset activate b")
     
      casecountB = spss.GetCaseCount()
     
     
      if casecountA > casecountB:
     
          spss.Submit(<one set
        of syntax>)
     
      else:
     
          spss.Submit(<the other
        set>)
     
      end program.
     
     
      Note that the case count is not
        always
        known if the data do not come from a sav file and the data have
        not been
        previously passed.
     
     
     
     
       
        Jon Peck (no "h") aka Kim
        Senior Software Engineer, IBM
        [hidden email]
        phone: 720-342-5621
     
     
     
     
     
      From:      
         albert_sun < [hidden email] >
     
      To:      
          [hidden email] ,
     
     
      Date:      
         07/25/2013 10:40 PM
     
      Subject:    
           [SPSSX-L] How
        to determine the number of cases within data
     
      Sent by:    
           "SPSSX(r)
        Discussion" < [hidden email] >
     
     
     
     
     
      hi,
         
          Given a data, is there a way of using syntax to determine the
          number of
          cases contained in it? The case scenario I want to use is that
          if size
          > A,
          go syntax A. If size <A, go syntax B.
         
          Thanks
         
         
         
          --
          View this message in context: http://spssx-discussion.1045642.n5.nabble.com/How-to-determine-the-number-of-cases-within-data-tp5721378.html 
          Sent from the SPSSX Discussion mailing list archive at
          Nabble.com.
         
          =====================
          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
         
       
     
     
     
     
     
        If you reply to this email, your
          message will be added to the discussion below:
        http://spssx-discussion.1045642.n5.nabble.com/How-to-determine-the-number-of-cases-within-data-tp5721378p5721383.html 
     
     
        To start a new topic under SPSSX Discussion, email
        [hidden email] 
        To unsubscribe from SPSSX Discussion, click
          here .
        NAML
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: How to determine the number of cases within data

Bruce Weaver
Administrator
Right!  Well-spotted!

David Marso wrote
Art's ex used MODE ADDVARIABLES ;-(
You would want to protect the DO IF blah blah with an outer
DO IF $CASENUM=1.
...
END IF.

-or-
AGGREGATE to an external DATASET.  Activate it.  Do the WRITE...
ACTIVATE the main data file of interest.
INSERT the file created from DMGHBHH .

-or-
Create a macro containing the two different syntax variants which accepts a positional argument.
DEFINE AorB (!POS !CMDEND).
....
!IF (!1 !EQ A) !THEN
....
code for syntax< criteria
!ELSE
 code for syntax >= criteria
!IFEND
!ENDDEFINE.

aggregate as before to external dataset.
DATASET DECLARE agg .
AGGREGATE OUTFILE agg / size=N.
DATASET ACTIVATE agg .
DO IF (size LT criteria).
WRITE OUTFILE blah / "AorB A".
ELSE.
WRITE OUTFILE blah / "AorB B".
END IF.
DATASET ACTIVATE rawdataofinterest.
INCLUDE blah .
ERASE FILE=blah.
DATASET CLOSE agg.

Bruce Weaver wrote
David's ginger-haired bastard "horrible hack" method would work.  (That's probably one of the approaches Jon was thinking about when he mentioned "very convoluted workarounds".)  I will admit that it has the disadvantage of requiring only native SPSS syntax.  :-|

The following is untested, but close to what you would need, I think.  (I assumed that for the second condition, you really wanted Size less than or equal to A, not just Size < A.)

* Compute Size with AGGREGATE as in Art's example.
DO IF Size GT A.
- WRITE OUTFILE = "C:\Temp\InsertCommand.sps" / "INSERT FILE = 'C:\MyFolder\SyntaxA.SPS'." .
ELSE IF Size LE A.
- WRITE OUTFILE = "C:\Temp\InsertCommand.sps" / "INSERT FILE = 'C:\MyFolder\SyntaxB.SPS'." .
END IF.
EXECUTE.
INSERT FILE = "C:\Temp\InsertCommand.sps".
ERASE FILE =  "C:\Temp\InsertCommand.sps".

The files SyntaxA.SPS and SyntaxB.SPS hold the two different versions of the syntax, of course.

Donning flame-proof suit & ducking for cover!  ;-)


David Marso wrote
This would only work if "..." contains ONLY transformation commands ;-(

Art Kendall wrote
I read the OP differently. Although I don't know what is wanted if size =
          A. A is hard coded in the syntax
            this is untested
          get file...
            aggregate
              .../mode=addvariables /size = n.
                compute A = 1234.
                do if size gt A.
                  ...
                      else if size lt A.
                        ...
                          else.
                            print /'oops  cannot pick
                              syntax set'/.
                          end
                if.
               
                However, I wonder why
                    the OP wants to do this.
             
      Art Kendall
Social Research Consultants
      On 7/26/2013 8:28 AM, Jon K Peck [via SPSSX Discussion] wrote:
   
     This would require
        the use of Python programmability
        unless you use some very convoluted workarounds.
     
     
      Something like this.
     
      begin program.
     
      spss.Submit("dataset activate a")
     
      casecountA = spss.GetCaseCount()
     
      spss.Submit("dataset activate b")
     
      casecountB = spss.GetCaseCount()
     
     
      if casecountA > casecountB:
     
          spss.Submit(<one set
        of syntax>)
     
      else:
     
          spss.Submit(<the other
        set>)
     
      end program.
     
     
      Note that the case count is not
        always
        known if the data do not come from a sav file and the data have
        not been
        previously passed.
     
     
     
     
       
        Jon Peck (no "h") aka Kim
        Senior Software Engineer, IBM
        [hidden email]
        phone: 720-342-5621
     
     
     
     
     
      From:      
         albert_sun < [hidden email] >
     
      To:      
          [hidden email] ,
     
     
      Date:      
         07/25/2013 10:40 PM
     
      Subject:    
           [SPSSX-L] How
        to determine the number of cases within data
     
      Sent by:    
           "SPSSX(r)
        Discussion" < [hidden email] >
     
     
     
     
     
      hi,
         
          Given a data, is there a way of using syntax to determine the
          number of
          cases contained in it? The case scenario I want to use is that
          if size
          > A,
          go syntax A. If size <A, go syntax B.
         
          Thanks
         
         
         
          --
          View this message in context: http://spssx-discussion.1045642.n5.nabble.com/How-to-determine-the-number-of-cases-within-data-tp5721378.html 
          Sent from the SPSSX Discussion mailing list archive at
          Nabble.com.
         
          =====================
          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
         
       
     
     
     
     
     
        If you reply to this email, your
          message will be added to the discussion below:
        http://spssx-discussion.1045642.n5.nabble.com/How-to-determine-the-number-of-cases-within-data-tp5721378p5721383.html 
     
     
        To start a new topic under SPSSX Discussion, email
        [hidden email] 
        To unsubscribe from SPSSX Discussion, click
          here .
        NAML
--
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: How to determine the number of cases within data

Albert-Jan Roskam
In reply to this post by Bruce Weaver
hmmm, this is still uglier *winks*, the only thing that's missing is arithmatics with !length and all. David, care to give it a go? ;-)))

aggregate outfile = * /size = n.
do if ( $casenum eq 1 ).
+ write outfile = "%temp%/size.sps" / "define !size () ", size, " !enddefine.".
end if.
insert file = "%temp%/size.sps".
define !runsyntax (syntax_a = !tokens(1), syntax_b = !tokens(1), !cutoff = !cmdend).
if ((!eval(!size) !lt !cutoff) !then
insert file = !syntax_a.
!else insert file = !syntax_b.
!ifend.
erase file = "%temp%/size.sps".
!enddefine.


Regards,
Albert-Jan


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a
fresh water system, and public health, what have the Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


----- Original Message -----

> From: Bruce Weaver <[hidden email]>
> To: [hidden email]
> Cc:
> Sent: Friday, July 26, 2013 7:56 PM
> Subject: Re: [SPSSX-L] How to determine the number of cases within data
>
> David's ginger-haired bastard "horrible hack" method would work.
> (That's
> probably one of the approaches Jon was thinking about when he mentioned
> "very convoluted workarounds".)  I will admit that it has the
> disadvantage
> of requiring only native SPSS syntax.  :-|
>
> The following is *untested*, but close to what you would need, I think.  (I
> assumed that for the second condition, you really wanted Size less than or
> equal to A, not just Size < A.)
>
> * Compute Size with AGGREGATE as in Art's example.
> DO IF Size GT A.
> - WRITE OUTFILE = "C:\Temp\InsertCommand.sps" / "INSERT
> FILE =
> 'C:\MyFolder\SyntaxA.SPS'." .
> ELSE IF Size LE A.
> - WRITE OUTFILE = "C:\Temp\InsertCommand.sps" / "INSERT
> FILE =
> 'C:\MyFolder\SyntaxB.SPS'." .
> END IF.
> EXECUTE.
> INSERT FILE = "C:\Temp\InsertCommand.sps".
> ERASE FILE =  "C:\Temp\InsertCommand.sps".
>
> The files SyntaxA.SPS and SyntaxB.SPS hold the two different versions of the
> syntax, of course.
>
> Donning flame-proof suit & ducking for cover!  ;-)
>
>
>
> David Marso wrote
>>  This would only work if "..." contains ONLY transformation
> commands ;-(
>>  Art Kendall wrote
>>>  I read the OP differently. Although I don't know what is wanted if
> size =
>>>            A. A is hard coded in the syntax
>>>              this is untested
>>>            get file...
>>>              aggregate
>>>                .../mode=addvariables /size = n.
>>>                  compute A = 1234.
>>>                  do if size gt A.
>>>                    ...
>>>                        else if size lt A.
>>>                          ...
>>>                            else.
>>>                              print /'oops&nbsp; cannot pick
>>>                                syntax set'/.
>>>                            end
>>>                  if.
>>>
>>>                  However, I wonder why
>>>                      the OP wants to do this.
>>>
>>>        Art Kendall
>>>  Social Research Consultants
>>>        On 7/26/2013 8:28 AM, Jon K Peck [via SPSSX Discussion] wrote:
>>>
>>>       This would require
>>>          the use of Python programmability
>>>          unless you use some very convoluted workarounds.
>>>
>>>
>>>        Something like this.
>>>
>>>        begin program.
>>>
>>>        spss.Submit("dataset activate a")
>>>
>>>        casecountA = spss.GetCaseCount()
>>>
>>>        spss.Submit("dataset activate b")
>>>
>>>        casecountB = spss.GetCaseCount()
>>>
>>>
>>>        if casecountA &gt; casecountB:
>>>
>>>        &nbsp; &nbsp; spss.Submit(&lt;one set
>>>          of syntax&gt;)
>>>
>>>        else:
>>>
>>>        &nbsp; &nbsp; spss.Submit(&lt;the other
>>>          set&gt;)
>>>
>>>        end program.
>>>
>>>
>>>        Note that the case count is not
>>>          always
>>>          known if the data do not come from a sav file and the data have
>>>          not been
>>>          previously passed.
>>>
>>>
>>>
>>>
>>>
>>>          Jon Peck (no "h") aka Kim
>>>          Senior Software Engineer, IBM
>>>          [hidden email]
>>>          phone: 720-342-5621
>>>
>>>
>>>
>>>
>>>
>>>        From: &nbsp; &nbsp; &nbsp;
>>>          &nbsp;albert_sun &lt; [hidden email] &gt;
>>>
>>>        To: &nbsp; &nbsp; &nbsp;
>>>          &nbsp; [hidden email] ,
>>>
>>>
>>>        Date: &nbsp; &nbsp; &nbsp;
>>>          &nbsp;07/25/2013 10:40 PM
>>>
>>>        Subject: &nbsp; &nbsp;
>>>          &nbsp; &nbsp;[SPSSX-L] How
>>>          to determine the number of cases within data
>>>
>>>        Sent by: &nbsp; &nbsp;
>>>          &nbsp; &nbsp;"SPSSX(r)
>>>          Discussion" &lt; [hidden email] &gt;
>>>
>>>
>>>
>>>
>>>
>>>        hi,
>>>
>>>            Given a data, is there a way of using syntax to determine the
>>>            number of
>>>            cases contained in it? The case scenario I want to use is
> that
>>>            if size
>>>            &gt; A,
>>>            go syntax A. If size &lt;A, go syntax B.
>>>
>>>            Thanks
>>>
>>>
>>>
>>>            --
>>>            View this message in context:
>>>
> http://spssx-discussion.1045642.n5.nabble.com/How-to-determine-the-number-of-cases-within-data-tp5721378.html
>>>            Sent from the SPSSX Discussion mailing list archive at
>>>            Nabble.com.
>>>
>>>            =====================
>>>            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
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>          If you reply to this email, your
>>>            message will be added to the discussion below:
>>>
>>>
> http://spssx-discussion.1045642.n5.nabble.com/How-to-determine-the-number-of-cases-within-data-tp5721378p5721383.html
>>>
>>>
>>>          To start a new topic under SPSSX Discussion, email
>>>
>
>>>  ml-node+s1045642n1068821h68@.nabble
>
>>>
>>>          To unsubscribe from SPSSX Discussion, click
>>>            here .
>>>          NAML
>
>
>
>
>
> -----
> --
> Bruce Weaver
> [hidden email]
> http://sites.google.com/a/lakeheadu.ca/bweaver/
>
> "When all else fails, RTFM."
>
> NOTE: My Hotmail account is not monitored regularly.
> To send me an e-mail, please use the address shown above.
>
> --
> View this message in context:
> http://spssx-discussion.1045642.n5.nabble.com/How-to-determine-the-number-of-cases-within-data-tp5721378p5721389.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> 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
>

=====================
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 determine the number of cases within data

David Marso
Administrator
Why would we need math and !LENGTH ?

Albert-Jan Roskam wrote
hmmm, this is still uglier *winks*, the only thing that's missing is arithmatics with !length and all. David, care to give it a go? ;-)))

aggregate outfile = * /size = n.
do if ( $casenum eq 1 ).
+ write outfile = "%temp%/size.sps" / "define !size () ", size, " !enddefine.".
end if.
insert file = "%temp%/size.sps".
define !runsyntax (syntax_a = !tokens(1), syntax_b = !tokens(1), !cutoff = !cmdend).
if ((!eval(!size) !lt !cutoff) !then
insert file = !syntax_a.
!else insert file = !syntax_b.
!ifend.
erase file = "%temp%/size.sps".
!enddefine.


Regards,
Albert-Jan


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a
fresh water system, and public health, what have the Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


----- Original Message -----
> From: Bruce Weaver <[hidden email]>
> To: [hidden email]
> Cc:
> Sent: Friday, July 26, 2013 7:56 PM
> Subject: Re: [SPSSX-L] How to determine the number of cases within data
>
> David's ginger-haired bastard "horrible hack" method would work.
> (That's
> probably one of the approaches Jon was thinking about when he mentioned
> "very convoluted workarounds".)  I will admit that it has the
> disadvantage
> of requiring only native SPSS syntax.  :-|
>
> The following is *untested*, but close to what you would need, I think.  (I
> assumed that for the second condition, you really wanted Size less than or
> equal to A, not just Size < A.)
>
> * Compute Size with AGGREGATE as in Art's example.
> DO IF Size GT A.
> - WRITE OUTFILE = "C:\Temp\InsertCommand.sps" / "INSERT
> FILE =
> 'C:\MyFolder\SyntaxA.SPS'." .
> ELSE IF Size LE A.
> - WRITE OUTFILE = "C:\Temp\InsertCommand.sps" / "INSERT
> FILE =
> 'C:\MyFolder\SyntaxB.SPS'." .
> END IF.
> EXECUTE.
> INSERT FILE = "C:\Temp\InsertCommand.sps".
> ERASE FILE =  "C:\Temp\InsertCommand.sps".
>
> The files SyntaxA.SPS and SyntaxB.SPS hold the two different versions of the
> syntax, of course.
>
> Donning flame-proof suit & ducking for cover!  ;-)
>
>
>
> David Marso wrote
>>  This would only work if "..." contains ONLY transformation
> commands ;-(
>>  Art Kendall wrote
>>>  I read the OP differently. Although I don't know what is wanted if
> size =
>>>            A. A is hard coded in the syntax
>>>              this is untested
>>>            get file...
>>>              aggregate
>>>                .../mode=addvariables /size = n.
>>>                  compute A = 1234.
>>>                  do if size gt A.
>>>                    ...
>>>                        else if size lt A.
>>>                          ...
>>>                            else.
>>>                              print /'oops  cannot pick
>>>                                syntax set'/.
>>>                            end
>>>                  if.
>>>
>>>                  However, I wonder why
>>>                      the OP wants to do this.
>>>
>>>        Art Kendall
>>>  Social Research Consultants
>>>        On 7/26/2013 8:28 AM, Jon K Peck [via SPSSX Discussion] wrote:
>>>
>>>       This would require
>>>          the use of Python programmability
>>>          unless you use some very convoluted workarounds.
>>>
>>>
>>>        Something like this.
>>>
>>>        begin program.
>>>
>>>        spss.Submit("dataset activate a")
>>>
>>>        casecountA = spss.GetCaseCount()
>>>
>>>        spss.Submit("dataset activate b")
>>>
>>>        casecountB = spss.GetCaseCount()
>>>
>>>
>>>        if casecountA > casecountB:
>>>
>>>            spss.Submit(<one set
>>>          of syntax>)
>>>
>>>        else:
>>>
>>>            spss.Submit(<the other
>>>          set>)
>>>
>>>        end program.
>>>
>>>
>>>        Note that the case count is not
>>>          always
>>>          known if the data do not come from a sav file and the data have
>>>          not been
>>>          previously passed.
>>>
>>>
>>>
>>>
>>>
>>>          Jon Peck (no "h") aka Kim
>>>          Senior Software Engineer, IBM
>>>          [hidden email]
>>>          phone: 720-342-5621
>>>
>>>
>>>
>>>
>>>
>>>        From:      
>>>           albert_sun < [hidden email] >
>>>
>>>        To:      
>>>            [hidden email] ,
>>>
>>>
>>>        Date:      
>>>           07/25/2013 10:40 PM
>>>
>>>        Subject:    
>>>             [SPSSX-L] How
>>>          to determine the number of cases within data
>>>
>>>        Sent by:    
>>>             "SPSSX(r)
>>>          Discussion" < [hidden email] >
>>>
>>>
>>>
>>>
>>>
>>>        hi,
>>>
>>>            Given a data, is there a way of using syntax to determine the
>>>            number of
>>>            cases contained in it? The case scenario I want to use is
> that
>>>            if size
>>>            > A,
>>>            go syntax A. If size <A, go syntax B.
>>>
>>>            Thanks
>>>
>>>
>>>
>>>            --
>>>            View this message in context:
>>>
> http://spssx-discussion.1045642.n5.nabble.com/How-to-determine-the-number-of-cases-within-data-tp5721378.html
>>>            Sent from the SPSSX Discussion mailing list archive at
>>>            Nabble.com.
>>>
>>>            =====================
>>>            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
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>          If you reply to this email, your
>>>            message will be added to the discussion below:
>>>
>>>
> http://spssx-discussion.1045642.n5.nabble.com/How-to-determine-the-number-of-cases-within-data-tp5721378p5721383.html
>>>
>>>
>>>          To start a new topic under SPSSX Discussion, email
>>>
>
>>>  ml-node+s1045642n1068821h68@.nabble
>
>>>
>>>          To unsubscribe from SPSSX Discussion, click
>>>            here .
>>>          NAML
>
>
>
>
>
> -----
> --
> Bruce Weaver
> [hidden email]
> http://sites.google.com/a/lakeheadu.ca/bweaver/
>
> "When all else fails, RTFM."
>
> NOTE: My Hotmail account is not monitored regularly.
> To send me an e-mail, please use the address shown above.
>
> --
> View this message in context:
> http://spssx-discussion.1045642.n5.nabble.com/How-to-determine-the-number-of-cases-within-data-tp5721378p5721389.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> 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
>

=====================
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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: How to determine the number of cases within data

albert_sun
Thanks for these replies, and I ill explain my original ideas behind the question. I have a student data with students' background information (gender, language, etc), test scores. I can use AGGREGATE command to get the number of students within each school in each background information (for example, female students in school 1111). I want to select the students with school size greater than 10, and if I directly use SELECT IF command and there is no subgroup size greater than 10, the SPSS will report error message like the dataset is empty. So I want to have a per-determinate condition before SELECT IF command.

Hope it is clear.



Reply | Threaded
Open this post in threaded view
|

Re: How to determine the number of cases within data

Rich Ulrich
So - It now sounds to me like the answer may be simpler
than you imagined.  You don't have to separate out any syntax,
after all.

You can do an Aggregate that creates N's for particular groups
and adds that count to all the respective records.  Then you
use FILTER to select the large enough sets and use SPLIT FILES
to generate all the subgroups that do exist on a particular variable,
across all the schools. 

The only way to "error out" would be if there were no subgroups
that met the criterion ... in which case, you probably should have
known that was not an interesting set for comparisons.

--
Rich Ulrich

> Date: Sun, 28 Jul 2013 16:15:44 -0700

> From: [hidden email]
> Subject: Re: How to determine the number of cases within data
> To: [hidden email]
>
> Thanks for these replies, and I ill explain my original ideas behind the
> question. I have a student data with students' background information
> (gender, language, etc), test scores. I can use AGGREGATE command to get the
> number of students within each school in each background information (for
> example, female students in school 1111). I want to select the students with
> school size greater than 10, and if I directly use SELECT IF command and
> there is no subgroup size greater than 10, the SPSS will report error
> message like the dataset is empty. So I want to have a per-determinate
> condition before SELECT IF command.
>
> Hope it is clear.
>
>
>
>
>
>
>
> --
> View this message in context: http://spssx-discussion.1045642.n5.nabble.com/How-to-determine-the-number-of-cases-within-data-tp5721378p5721407.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> 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