Quantcast

Automatic numbering

classic Classic list List threaded Threaded
6 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Automatic numbering

Humphrey Paulie
Hi everyone,
  I have defined a new variable in my SPSS file. This is students' IDs. I want to number them from 1-6543. How can I automatically do it?
  How can I tell the programm to write form 1 to 6543 in one column?
  I really do not want to do it by hand.
  Thanks for your help
  Humphrey


---------------------------------
Do you Yahoo!?
 Get on board. You're invited to try the new Yahoo! Mail Beta.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Automatic numbering

Anton Balabanov
Happily, this is quite simple to do with two syntax commands:

compute id=$casenum.
execute.

Best,
Anton

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of
Humphrey
Sent: Monday, June 19, 2006 1:26 PM
To: [hidden email]
Subject: Automatic numbering


Hi everyone,
  I have defined a new variable in my SPSS file. This is students' IDs. I
want to number them from 1-6543. How can I automatically do it?
  How can I tell the programm to write form 1 to 6543 in one column?
  I really do not want to do it by hand.
  Thanks for your help
  Humphrey


---------------------------------
Do you Yahoo!?
 Get on board. You're invited to try the new Yahoo! Mail Beta.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Automatic numbering

Omar Farook
Dear Mr. Anton,
  Suppose there is no other variable in the database except the IDs.
  How SPSS will know that the last case is 6543?
  Many thanks.
  Omar.

Anton Balabanov <[hidden email]> wrote:  Happily, this is quite simple to do with two syntax commands:

compute id=$casenum.
execute.

Best,
Anton

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of
Humphrey
Sent: Monday, June 19, 2006 1:26 PM
To: [hidden email]
Subject: Automatic numbering


Hi everyone,
I have defined a new variable in my SPSS file. This is students' IDs. I
want to number them from 1-6543. How can I automatically do it?
How can I tell the programm to write form 1 to 6543 in one column?
I really do not want to do it by hand.
Thanks for your help
Humphrey


---------------------------------
Do you Yahoo!?
Get on board. You're invited to try the new Yahoo! Mail Beta.


 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Automatic numbering

Anton Balabanov
Dear Omar,
this is the different topic. Indeed, I supposed from the original question
that Humphrey has already had the database of 6543 students. If the db is
still emty, the following approach could be used:
(for completely emty file (i.e., no one var is defined))

INPUT PROGRAM.
LOOP id=1 to 6543.
END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.
EXECUTE.

HTH,
Anton


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Omar
Farook
Sent: Monday, June 19, 2006 2:11 PM
To: [hidden email]
Subject: Re: Automatic numbering


Dear Mr. Anton,
  Suppose there is no other variable in the database except the IDs.
  How SPSS will know that the last case is 6543?
  Many thanks.
  Omar.

Anton Balabanov <[hidden email]> wrote:  Happily, this is quite
simple to do with two syntax commands:

compute id=$casenum.
execute.

Best,
Anton

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of
Humphrey
Sent: Monday, June 19, 2006 1:26 PM
To: [hidden email]
Subject: Automatic numbering


Hi everyone,
I have defined a new variable in my SPSS file. This is students' IDs. I
want to number them from 1-6543. How can I automatically do it?
How can I tell the programm to write form 1 to 6543 in one column?
I really do not want to do it by hand.
Thanks for your help
Humphrey


---------------------------------
Do you Yahoo!?
Get on board. You're invited to try the new Yahoo! Mail Beta.


 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Automatic numbering - amendment

Anton Balabanov
If you have only first n cases, n<6543, already entered to the file, but for
some reason need the id variable to be marked up to 6543, this will require
a bit more manipulations with the data:

*First, get the ID marked up to 6543.
INPUT PROGRAM.
LOOP id=1 to 6543.
END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.
EXECUTE.
SAVE OUTFILE='c:\temp\ids.sav'.

*Second, load your data and sort it by id.
GET FILE='c:\program files\spsseval\employee data.sav'. /*This is your data
file */
SORT CASES BY id.

*Third, join two files.
MATCH FILES /FILE=*
 /FILE='C:\temp\ids.sav'
 /BY id.   /* If your data file has no ID var yet, just remove this
subcommant entirely, as well as SORT instruction above */
EXECUTE.

All the best,
Anton


-----Original Message-----
From: Anton Balabanov [mailto:[hidden email]]
Sent: Monday, June 19, 2006 2:32 PM
To: Omar Farook; [hidden email]
Subject: RE: Automatic numbering


Dear Omar,
this is the different topic. Indeed, I supposed from the original question
that Humphrey has already had the database of 6543 students. If the db is
still emty, the following approach could be used:
(for completely emty file (i.e., no one var is defined))

INPUT PROGRAM.
LOOP id=1 to 6543.
END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.
EXECUTE.

HTH,
Anton


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Omar
Farook
Sent: Monday, June 19, 2006 2:11 PM
To: [hidden email]
Subject: Re: Automatic numbering


Dear Mr. Anton,
  Suppose there is no other variable in the database except the IDs.
  How SPSS will know that the last case is 6543?
  Many thanks.
  Omar.

Anton Balabanov <[hidden email]> wrote:  Happily, this is quite
simple to do with two syntax commands:

compute id=$casenum.
execute.

Best,
Anton

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of
Humphrey
Sent: Monday, June 19, 2006 1:26 PM
To: [hidden email]
Subject: Automatic numbering


Hi everyone,
I have defined a new variable in my SPSS file. This is students' IDs. I
want to number them from 1-6543. How can I automatically do it?
How can I tell the programm to write form 1 to 6543 in one column?
I really do not want to do it by hand.
Thanks for your help
Humphrey


---------------------------------
Do you Yahoo!?
Get on board. You're invited to try the new Yahoo! Mail Beta.


 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Automatic numbering - amendment

Richard Ristow
At 06:49 AM 6/19/2006, Anton Balabanov wrote:

>*First, get the ID marked up to 6543.
>INPUT PROGRAM.
>LOOP id=1 to 6543.
>END CASE.
>END LOOP.
>END FILE.
>END INPUT PROGRAM.
>EXECUTE.
>SAVE OUTFILE='c:\temp\ids.sav'.
>
>*Second, load your data and sort it by id.
>GET FILE='c:\program files\spsseval\employee
>data.sav'. /*This is your data
>file */
>SORT CASES BY id.
>
>*Third, join two files.
>MATCH FILES /FILE=*
>  /FILE='C:\temp\ids.sav'
>  /BY id.   /* If your data file has no ID var yet, just remove this
>subcommant entirely, as well as SORT instruction above */
>EXECUTE.

This is very nice code, and a nice technique.

However, to repeat an oft-made point: None of the
EXECUTE statements are necessary or helpful. That
also applies to EXECUTE statements in other postings in this series.

Not only are EXECUTE statements rarely useful;
the slow down processing by forcing the entire
file to be read. (However, I'm sure you won't
notice that with as few as 6543 cases.)

See  section "Use EXECUTE Sparingly" in Raynald
Levesque's book: Levesque, Raynald, "SPSS®
Programming and Data Management, 2nd Edition/A
Guide for SPSS® and SAS® Users". SPSS, Inc., Chicago, IL, 2005.
(Downloadable free from the SPSS, Inc., Web site.)
Loading...