Syntax to Create New Variable That Numbers Cases Starting From a Specified Value SOLVED

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

Syntax to Create New Variable That Numbers Cases Starting From a Specified Value SOLVED

james.moffitt

Sorry about jumping the gun on the  earlier post. I figured it out myself.

 

COMPUTE New=$CASENUM.

EXE.

COMPUTE New1 = New+45266 .

EXECUTE .

 

 

Reply | Threaded
Open this post in threaded view
|

Re: Syntax to Create New Variable That Numbers Cases Starting From a Specified Value SOLVED

William Dudley WNDUDLEY

James ,

You might also consider using the lag function
first
Compute new = 45266.
then
Compute new = lag(new) + 1.


William N. Dudley, PhD
Associate Dean for Research
The School of Health and Human Performance Office of Research
The University of North Carolina at Greensboro
126 HHP Building, PO Box 26170
Greensboro, NC 27402-6170
VOICE 336.2562475
FAX 336.334.3238



[hidden email]
Sent by: "SPSSX(r) Discussion" <[hidden email]>

04/02/2009 10:31 AM

Please respond to
[hidden email]

To
[hidden email]
cc
Subject
Syntax to Create New Variable That Numbers Cases Starting From a              Specified Value SOLVED





Sorry about jumping the gun on the  earlier post. I figured it out myself.
 
COMPUTE New=$CASENUM.
EXE.
COMPUTE New1 = New+45266 .
EXECUTE .
 
 
Reply | Threaded
Open this post in threaded view
|

EXECUTE (was, re: Syntax to Create New Variable That Numbers Cases ...)

Richard Ristow
In reply to this post by james.moffitt
At 08:43 AM 4/2/2009, [hidden email] wrote:

I figured this out myself.
 
COMPUTE New=$CASENUM.
EXE.
COMPUTE New1 = New+45266 .
EXECUTE .

Quite right. Matthew Pirritano's solution is the simplest, but yours works fine.

But I think it's time to say this again: Those EXECUTE statement are not necessary. They do nothing helpful. And, if your file is large, they can slow your processing significantly.

See section "Use EXECUTE Sparingly" in any edition of "SPSS® Programming and Data Management":

Levesque, Raynald, SPSS® Programming and Data Management/ A Guide for SPSS® and SAS® Users. SPSS, Inc., Chicago, IL

2nd edition: 2005
3rd edition (co-author, SPSS, Inc.): 2006
4th edition (co-author, SPSS, Inc.): 2007
(I think the 5th edition is on the site, now)

====================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: EXECUTE (was, re: Syntax to Create New Variable That Numbers Cases ...)

james.moffitt

True. Thanks for the reminder. J

 

From: Richard Ristow [mailto:[hidden email]]
Sent: Thursday, April 02, 2009 1:27 PM
To: Moffitt, James (West); [hidden email]
Cc: Pirritano, Matthew
Subject: EXECUTE (was, re: Syntax to Create New Variable That Numbers Cases ...)

 

At 08:43 AM 4/2/2009, [hidden email] wrote:


I figured this out myself.
 
COMPUTE New=$CASENUM.
EXE.
COMPUTE New1 = New+45266 .
EXECUTE .


Quite right. Matthew Pirritano's solution is the simplest, but yours works fine.

But I think it's time to say this again: Those EXECUTE statement are not necessary. They do nothing helpful. And, if your file is large, they can slow your processing significantly.

See section "Use EXECUTE Sparingly" in any edition of "SPSS® Programming and Data Management":

Levesque, Raynald, SPSS® Programming and Data Management/ A Guide for SPSS® and SAS® Users. SPSS, Inc., Chicago, IL

2nd edition: 2005
3rd edition (co-author, SPSS, Inc.): 2006
4th edition (co-author, SPSS, Inc.): 2007
(I think the 5th edition is on the site, now)