## Creating ID numbers in preferenced order

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

lotte
Posts: 2
Joined: Thu Feb 04, 2016 9:33 am

### Creating ID numbers in preferenced order

I would be very delighted if somebody can help me out. See below a part of my data set:

CIN---------------Serial number
00401065315-------------1
00401065315-------------2
00401065315-------------3
00510018026-01 ---------1
00510018026-01---------2
00512088627-------------1
00512088627-------------2
00512088627-------------3
00607057725-01 ---------1
00607057725-01---------2

I would like to see the following data set (because I've to merge another file with this file and they need an identical variabele):

CIN-------------Serial number-----Number-------Primary first
00401065315-----------1----------------1------------------1
00401065315-----------2----------------1
00401065315-----------3----------------1
00510018026-01-------1----------------2------------------1
00510018026-01-------2----------------2
00512088627-----------1----------------3------------------1
00512088627-----------2----------------3
00512088627-----------3----------------3
00607057725-01 2-----1----------------4------------------1
00607057725-01 2-----2----------------4

How do I create the 'number' variabele? I already tried this one:
do if (PrimaryFirst EQ 1).
compute ID = \$casenum.
else.
compute ID = lag(ID).
end if.
execute.

It works but the numbers are not in order I want to.
Numbers are like: 1 1 1 4 4 6 6 6 9 9 (instead of 1 1 1 2 2 3 3 3 4 4)

Anyone who knows a solution? You'll be very welcome thanks!

I also posted this subject in 'syntax', don't know which forum is best fitted.
GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

### Re: Creating ID numbers in preferenced order

maybe you can simply use automatic recode?
lotte
Posts: 2
Joined: Thu Feb 04, 2016 9:33 am

### Re: Creating ID numbers in preferenced order

Woow that makes me feel stupid haha, it works. Many thanks!

### Who is online

Users browsing this forum: No registered users and 1 guest