creating ID numbers in SPSS

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

Linda H
Posts: 3
Joined: Tue Feb 02, 2016 1:33 pm

creating ID numbers in SPSS

Postby Linda H » Tue Feb 02, 2016 1:54 pm

Hi All,
i'm very new to SPSS so apologies if my question is stupid.
We have a database with over 8000 cases so far and i need to generate ID numbers for each case, so that we can anonymize our data.
I've been looking online on how to do this but all i could find was either:
- creating IDs for a blank dataset using "syntax and loop program" or
- if you already have an existing dataset you can create ID numbers for the already existing cases using "transform - compute - $casenum"
What i need though is to be able to create ID numbers for already existing cases AND for SPSS to create an ID number every time i create a new case keeping the already existing ones even if i insert a case.
Is this at all possible?
I'm stuck, any help would be appreciated.
Thanks very much.
Linda
GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

Re: creating ID numbers in SPSS

Postby GerineL » Tue Feb 02, 2016 2:02 pm

you can do this the first time:

Code: Select all

compute IDnumber = $casenum.
execute.
if you add cases later:

Code: Select all

sort cases by IDnumber (d).
do if missing(IDnumber).
compute IDnumber = $casenum.
end if.
execute.
Linda H
Posts: 3
Joined: Tue Feb 02, 2016 1:33 pm

Re: creating ID numbers in SPSS

Postby Linda H » Tue Feb 02, 2016 2:39 pm

Thank you very much for your reply.
I've tried it, this way i ended up with duplicated ID numbers.
What am i doing wrong? Is there a way to fix this?
Linda H
Posts: 3
Joined: Tue Feb 02, 2016 1:33 pm

Re: creating ID numbers in SPSS

Postby Linda H » Tue Feb 02, 2016 4:49 pm

Oh, i see! I sorted it ascending...
Thanks very much for your help

Who is online

Users browsing this forum: No registered users and 1 guest

cron