how many cases

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

how many cases

Moon Kid
I just want to know how many cases are in my dataset. Something like
$CASEN.

I need to know it after the commands
TEMPORARY.
SELECT IF v46c = 5.

In some situations there is noc v46c=5 so no case is selected and the
current/temporary dataset is empty.

Then a FREQUENCIES causes errors messages. I want to check it before.

I need something like

IF case_n GT 0 THEN
  FREQUENCIES...
FI.

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

Jignesh Sutar
Best approach would be to use Python Programmability. If you are looping through all values of a categorical variable, then first aggregate on that variable to find non-zero categories then use spssdata fetchall to find their value codes and then loop through this in a python loop.

HTH,
Jignesh




On 6 May 2014 16:05, Moon Kid <[hidden email]> wrote:
I just want to know how many cases are in my dataset. Something like
$CASEN.

I need to know it after the commands
TEMPORARY.
SELECT IF v46c = 5.

In some situations there is noc v46c=5 so no case is selected and the
current/temporary dataset is empty.

Then a FREQUENCIES causes errors messages. I want to check it before.

I need something like

IF case_n GT 0 THEN
  FREQUENCIES...
FI.

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

Albert-Jan Roskam
In reply to this post by Moon Kid
________________________________

> From: Moon Kid <[hidden email]>
>To: [hidden email]
>Sent: Tuesday, May 6, 2014 5:05 PM
>Subject: [SPSSX-L] how many cases
>
>
>I just want to know how many cases are in my dataset. Something like
>$CASEN.
>
>I need to know it after the commands
>TEMPORARY.
>SELECT IF v46c = 5.
>
>In some situations there is noc v46c=5 so no case is selected and the
>current/temporary dataset is empty.
>
>Then a FREQUENCIES causes errors messages. I want to check it before.
>
>I need something like
>
>IF case_n GT 0 THEN
>  FREQUENCIES...
>FI.

Hi,

You can use SHOW N to get the current number of cases. But that's probably not what you are looking for.

The SPSS macro facility has an !if-!ifend structure that could do what you want, but you still need to assign the number of cases to e.g a macro. And then you still need to be aware that the macro operators (!eq, !gt, etc) just make string comparisons (01 > 1 evaluates to false). There are ways around that, too, but...

...Python to the rescue!

BEGIN PROGRAM.
import spss
if spss.GetCaseCount():

   spss.Submit("frequencies var1.")
END PROGRAM.


Regards,
Albert-Jan

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

Moon Kid
On 2014-05-06 08:46 Albert-Jan Roskam <[hidden email]> wrote:
> You can use SHOW N to get the current number of cases.

Yes that is the correct information I need.

> But that's probably not what you are looking for.

Yes, it is in the wrong format. I need it as variable or something I
can compute on.

> you still need to assign the number of cases to
> e.g a macro.

Yes that is what I want.

And no I will not use Phyton for such a simple case. SPSS is a
data-processing software and is not able to tell me how much rows are
currently in it?

I will not believe it even if it is SPSS! There must be an easier
solution.

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

Andy W
In reply to this post by Albert-Jan Roskam
spss.GetCaseCount() doesn't respect any current filters on the dataset - so that example won't work with TEMPORARY (like I think the OP wants).

****************************************.
DATA LIST FREE / X.
BEGIN DATA
1
2
3
END DATA.

BEGIN PROGRAM.
import spss
print spss.GetCaseCount()
END PROGRAM.

TEMPORARY.
SELECT IF X = 1.
BEGIN PROGRAM.
import spss
print spss.GetCaseCount()
END PROGRAM.
****************************************.

Another way using Python though is to fetch the data and then see if the array is empty.

****************************************.
TEMPORARY.
SELECT IF X = 4.
BEGIN PROGRAM.
import spss, spssdata
alldata = spssdata.Spssdata().fetchall()
print len(alldata)
END PROGRAM.
EXECUTE.
****************************************.
Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: how many cases

Alan Howard
In reply to this post by Moon Kid
AGGREGATE
   /OUTFILE=* MODE=ADDVARIABLES
   /TOTAl_N=N.


On 5/6/2014 12:15 PM, Moon Kid wrote:

> On 2014-05-06 08:46 Albert-Jan Roskam <[hidden email]> wrote:
>> You can use SHOW N to get the current number of cases.
> Yes that is the correct information I need.
>
>> But that's probably not what you are looking for.
> Yes, it is in the wrong format. I need it as variable or something I
> can compute on.
>
>> you still need to assign the number of cases to
>> e.g a macro.
> Yes that is what I want.
>
> And no I will not use Phyton for such a simple case. SPSS is a
> data-processing software and is not able to tell me how much rows are
> currently in it?
>
> I will not believe it even if it is SPSS! There must be an easier
> solution.
>
> =====================
> 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

--
Alan Howard
Statistical Software Support & Consulting Services
115 Bailey/Howe Library
University of Vermont
Burlington, VT  05405
802-656-2009

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

Moon Kid
In reply to this post by Andy W
On 2014-05-06 09:18 Andy W <[hidden email]> wrote:

> ****************************************.
> TEMPORARY.
> SELECT IF X = 4.
> BEGIN PROGRAM.
> import spss, spssdata
> alldata = spssdata.Spssdata().fetchall()
> print len(alldata)
> END PROGRAM.
> EXECUTE.
> ****************************************.

Doesn't work.

[err]
TEMPORARY.
SELECT IF (v46c = 5).
BEGIN PROGRAM.
import spss, spssdata
alldata = spssdata.Spssdata().fetchall()
print len(alldata)
END PROGRAM.
Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File
"C:\PROGRA~1\IBM\SPSS\STATIS~1\22\Python\Lib\site-packages\spssdata\spssdata.py",
line 741, in fetchall rows = self.cur.fetchall() File
"C:\PROGRA~1\IBM\SPSS\STATIS~1\22\Python\Lib\site-packages\spss\cursors.py",
line 1272, in fetchall data.append(self.binaryStream.fetchData()) File
"C:\PROGRA~1\IBM\SPSS\STATIS~1\22\Python\Lib\site-packages\spss\binarystream.py",
line 813, in fetchData data = self.nextcase() File
"C:\PROGRA~1\IBM\SPSS\STATIS~1\22\Python\Lib\site-packages\spss\binarystream.py",
line 758, in nextcase tempdata =
self.readdataCache[self.cachePos:(self.cachePos+self.caseLen)]
TypeError: 'NoneType' object is not subscriptable EXECUTE.
[/err]

--
<http://dontbubble.us/>

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

Moon Kid
In reply to this post by Alan Howard
On 2014-05-06 12:22 Alan Howard <[hidden email]> wrote:
> AGGREGATE
>    /OUTFILE=* MODE=ADDVARIABLES
>    /TOTAl_N=N.

This causes an error because there is an outfile without cases.

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

Rick Oliver-3
In reply to this post by Moon Kid
In your example, the application does not know how many cases are in the file until it executes the FREQUENCIES procedure, because it does not execute the temporary selection until it executes the FREQUENCIES procedure. Transformations (like SELECT IF) are designed to be efficient by delaying execution until there is a command that requires a data pass (such as the FREQUENCIES procedure).

You could EXECUTE the SELECT IF first, but not with a TEMPORARY command, and you would still need Python to conditionally execute based on the case count. You could use datasets to get the same effect as temporary. As in:

data list free /x.
begin data
1 2 3 4 5 6
end data.
dataset name one.
dataset copy two.
dataset activate two.
select if x > 10.
execute.
begin program.
import spss
casecount=spss.GetCaseCount()
print (casecount)
if casecount > 0:
  spss.Submit("frequencies variables=x.")
else:
  print("File has no cases.")
end program.
dataset delete two.

There are probably more elegant solutions.



Rick Oliver
Senior Information Developer
IBM Business Analytics (SPSS)
E-mail: [hidden email]




From:        Moon Kid <[hidden email]>
To:        [hidden email],
Date:        05/06/2014 11:20 AM
Subject:        Re: how many cases
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




On 2014-05-06 08:46 Albert-Jan Roskam <[hidden email]> wrote:
> You can use SHOW N to get the current number of cases.

Yes that is the correct information I need.

> But that's probably not what you are looking for.

Yes, it is in the wrong format. I need it as variable or something I
can compute on.

> you still need to assign the number of cases to
> e.g a macro.

Yes that is what I want.

And no I will not use Phyton for such a simple case. SPSS is a
data-processing software and is not able to tell me how much rows are
currently in it?

I will not believe it even if it is SPSS! There must be an easier
solution.

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

Jon K Peck
In reply to this post by Albert-Jan Roskam
While the Python solution would work well in most cases, it does not work here, because spss.GetCaseCount does not see the temporary select if.  In fact,  because the temporary selection is actually applied during the data pass for the FREQUENCIES command, it is not known until after all the data are passed that there are actually no cases.  While you could use AGGREGATE to figure out the case counts and then use Python code for flow control to avoid the error, that may be more complexity than you want to sign up for.  You could, however, use OMS to suppress the Warnings table from the Viewer, .e.g
oms select warnings/destination viewer=no.
temporary.
select if ....
freq jobcat.
...
omsend.

That would leave an empty Frequencies title but no other output from the command.


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




From:        Albert-Jan Roskam <[hidden email]>
To:        [hidden email],
Date:        05/06/2014 09:50 AM
Subject:        Re: [SPSSX-L] how many cases
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




________________________________
> From: Moon Kid <[hidden email]>
>To: [hidden email]
>Sent: Tuesday, May 6, 2014 5:05 PM
>Subject: [SPSSX-L] how many cases
>
>
>I just want to know how many cases are in my dataset. Something like
>$CASEN.
>
>I need to know it after the commands
>TEMPORARY.
>SELECT IF v46c = 5.
>
>In some situations there is noc v46c=5 so no case is selected and the
>current/temporary dataset is empty.
>
>Then a FREQUENCIES causes errors messages. I want to check it before.
>
>I need something like
>
>IF case_n GT 0 THEN
>  FREQUENCIES...
>FI.

Hi,

You can use SHOW N to get the current number of cases. But that's probably not what you are looking for.

The SPSS macro facility has an !if-!ifend structure that could do what you want, but you still need to assign the number of cases to e.g a macro. And then you still need to be aware that the macro operators (!eq, !gt, etc) just make string comparisons (01 > 1 evaluates to false). There are ways around that, too, but...

...Python to the rescue!

BEGIN PROGRAM.
import spss
if spss.GetCaseCount():

  spss.Submit("frequencies var1.")
END PROGRAM.


Regards,
Albert-Jan

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

Moon Kid
In reply to this post by Moon Kid
What do you think about this (doesn't work correct)

TEMPORARY.
SELECT IF (v46c = 5).
COMPUTE killme = $casenum.
!IF (killme GT 0) !THEN
 FREQUENCIES VARIABLES=v46s
   /ORDER=ANALYSIS
!FI

The IF-statement doesn't work. But "killme" has the correct value (0).
The IF looks like in the documentation.
--
<http://dontbubble.us/>

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

David Marso
Administrator
In reply to this post by Albert-Jan Roskam
Doesn't seem to work when TEMPORARY is in effect.
Method returns the total number of cases in the file not the number remaining after
TEMPORARY.
SELECT IF condition ;-((
So maybe OP would like to present the larger picture.
What is the goal of this?
Why should an error due to there not being any valid cases be a showstopper?
Live with it!
---
Albert-Jan Roskam wrote
________________________________
> From: Moon Kid <[hidden email]>
>To: [hidden email]
>Sent: Tuesday, May 6, 2014 5:05 PM
>Subject: [SPSSX-L] how many cases
>
>
>I just want to know how many cases are in my dataset. Something like
>$CASEN.
>
>I need to know it after the commands
>TEMPORARY.
>SELECT IF v46c = 5.
>
>In some situations there is noc v46c=5 so no case is selected and the
>current/temporary dataset is empty.
>
>Then a FREQUENCIES causes errors messages. I want to check it before.
>
>I need something like
>
>IF case_n GT 0 THEN
>  FREQUENCIES...
>FI.

Hi,

You can use SHOW N to get the current number of cases. But that's probably not what you are looking for.

The SPSS macro facility has an !if-!ifend structure that could do what you want, but you still need to assign the number of cases to e.g a macro. And then you still need to be aware that the macro operators (!eq, !gt, etc) just make string comparisons (01 > 1 evaluates to false). There are ways around that, too, but...

...Python to the rescue!

BEGIN PROGRAM.
import spss
if spss.GetCaseCount():

   spss.Submit("frequencies var1.")
END PROGRAM.


Regards,
Albert-Jan

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

Moon Kid
On 2014-05-06 09:32 David Marso <[hidden email]> wrote:
> So maybe OP would like to present the larger picture.
> What is the goal of this?

v46c represents the answer of a question with 6 (0-5) possible values.

'5' means "something else" and points to a free-text field (v46s).

If the free-text field is used (v46c = 5) then I want to show the
values of v46s. That's all.

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

David Marso
Administrator
In reply to this post by Moon Kid
Read up on macros!
The !IF within DEFINE !ENDDEFINE doesn't know squat about the values in the data.
!IF can ONLY be used in a DEFINE !ENDDEINE block and should not be confused with IF or DO IF which are used in the context of data transformations and CANNOT BE USED TO CONTROL the conditional execution of PROCEDURES.
Rather than continue to beat your head against the brick wall why not use PRINT within a DO IF?

DO IF  (v46c = 5).
PRINT / v46s.
END IF.
EXECUTE.

OTOH if you expect a lot of duplicate values within the text use AGGREGATE first.

Moon Kid wrote
What do you think about this (doesn't work correct)

TEMPORARY.
SELECT IF (v46c = 5).
COMPUTE killme = $casenum.
!IF (killme GT 0) !THEN
 FREQUENCIES VARIABLES=v46s
   /ORDER=ANALYSIS
!FI

The IF-statement doesn't work. But "killme" has the correct value (0).
The IF looks like in the documentation.
--
<http://dontbubble.us/>

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

Moon Kid
In reply to this post by Jon K Peck
On 2014-05-06 11:31 Jon K Peck <[hidden email]> wrote:
> Are you running these scripts using the INSERT command?  It allows
> you to specify whether to continue on error or stop
> (ERROR=CONTINUE|STOP).

I am using INSERT. And CONTINUE is the default behavior but doesn't fix
my problem.

If there is an error the calling (main) script is continued but the
error causing subscript is stop.

I need the subscript going on because using FREQUENCIES on a variable
with no cases is not an error for me.

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

Moon Kid
In reply to this post by David Marso
On 2014-05-06 10:18 David Marso <[hidden email]> wrote:
> DO IF  (v46c = 5).
> PRINT / v46s.
> END IF.
> EXECUTE.

It is a nice workaround and I can live with it.

The output is ugly. ;)

And I don't understand the concept behind it. Why is PRINT a
transformation command (execute is needed). It displays values.
--
<http://dontbubble.us/>

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

Jon K Peck
In reply to this post by Moon Kid
I read the INSERT doc saying it would continue to run the syntax with ERROR=CONTINUE, but what it means is that the INSERTed file stops running but commands in the stream that invoked INSERT would continue to be run.

It is possible with programmability to get finer grained control, but you would need to run all the commands within a Python block to do that.  I can provide details if you decide to go that way


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




From:        Moon Kid <[hidden email]>
To:        [hidden email],
Date:        05/07/2014 12:15 PM
Subject:        Re: [SPSSX-L] how many cases
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




On 2014-05-06 11:31 Jon K Peck <[hidden email]> wrote:
> Are you running these scripts using the INSERT command?  It allows
> you to specify whether to continue on error or stop
> (ERROR=CONTINUE|STOP).

I am using INSERT. And CONTINUE is the default behavior but doesn't fix
my problem.

If there is an error the calling (main) script is continued but the
error causing subscript is stop.

I need the subscript going on because using FREQUENCIES on a variable
with no cases is not an error for me.

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

Rick Oliver-3
ERROR=CONTINUE (the default behavior) should do what it sounds like it should do: Continue to run the commands in the inserted file after encountering an error, and that's what it does in my simple tests.


Rick Oliver
Senior Information Developer
IBM Business Analytics (SPSS)
E-mail: [hidden email]




From:        Jon K Peck/Chicago/IBM@IBMUS
To:        [hidden email],
Date:        05/07/2014 02:39 PM
Subject:        Re: how many cases
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




I read the INSERT doc saying it would continue to run the syntax with ERROR=CONTINUE, but what it means is that the INSERTed file stops running but commands in the stream that invoked INSERT would continue to be run.

It is possible with programmability to get finer grained control, but you would need to run all the commands within a Python block to do that.  I can provide details if you decide to go that way



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





From:        
Moon Kid <[hidden email]>
To:        
[hidden email],
Date:        
05/07/2014 12:15 PM
Subject:        
Re: [SPSSX-L] how many cases
Sent by:        
"SPSSX(r) Discussion" <[hidden email]>




On 2014-05-06 11:31 Jon K Peck <[hidden email]> wrote:
> Are you running these scripts using the INSERT command?  It allows
> you to specify whether to continue on error or stop
> (ERROR=CONTINUE|STOP).

I am using INSERT. And CONTINUE is the default behavior but doesn't fix
my problem.

If there is an error the calling (main) script is continued but the
error causing subscript is stop.

I need the subscript going on because using FREQUENCIES on a variable
with no cases is not an error for me.

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

Rich Ulrich
In reply to this post by Moon Kid
PRINT does not cause a data-pass to occur, and that is why EXE is needed.

I think of it as setting a flag.  Thus, if you have several PRINTs , they will be
run in the same reading of the file -- their results will be intermixed -- and
not in separate passes. 

--
Rich Ulrich

> Date: Wed, 7 May 2014 20:14:41 +0200

> From: [hidden email]
> Subject: Re: how many cases
> To: [hidden email]
>
> On 2014-05-06 10:18 David Marso <[hidden email]> wrote:
> > DO IF (v46c = 5).
> > PRINT / v46s.
> > END IF.
> > EXECUTE.
>
> It is a nice workaround and I can live with it.
>
> The output is ugly. ;)
>
> And I don't understand the concept behind it. Why is PRINT a
> transformation command (execute is needed). It displays values.
> --
...
Reply | Threaded
Open this post in threaded view
|

Re: how many cases

Jon K Peck
Fundamentally, print is a transformation because it operates independently on each case.  Thus it is like a transformation function and not like a procedure.  Because it is a transformation, you can use it in loops and conditionals, which would not be possible for a procedure (i.e., a non-transformation).


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




From:        Rich Ulrich <[hidden email]>
To:        [hidden email],
Date:        05/07/2014 06:39 PM
Subject:        Re: [SPSSX-L] how many cases
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




PRINT does not cause a data-pass to occur, and that is why EXE is needed.

I think of it as setting a flag.  Thus, if you have several PRINTs , they will be
run in the same reading of the file -- their results will be intermixed -- and
not in separate passes.  

--
Rich Ulrich

> Date: Wed, 7 May 2014 20:14:41 +0200
> From: [hidden email]
> Subject: Re: how many cases
> To: [hidden email]
>
> On 2014-05-06 10:18 David Marso <[hidden email]> wrote:
> > DO IF (v46c = 5).
> > PRINT / v46s.
> > END IF.
> > EXECUTE.
>
> It is a nice workaround and I can live with it.
>
> The output is ugly. ;)
>
> And I don't understand the concept behind it. Why is PRINT a
> transformation command (execute is needed). It displays values.
> --
...

12