Help using Base SAS procedures

How to assign a unique ID number to each group of identical values in a column?

Reply
Occasional Contributor
Posts: 10

How to assign a unique ID number to each group of identical values in a column?

?my data:

accname

=======

abc

abc

xyz

abc

def

xyz

def

desired output:

accname         uniqid

=======        =====

abc                    1

abc                    1

xyz                    2

abc                    1

def                     3

xyz                    1

def                     3

Super Contributor
Posts: 490

Re: How to assign a unique ID number to each group of identical values in a column?

proc sort data=have;

by accname;

run;

data want;

set have;

by accname;

retain order 0;

if first.accname then order=order+1;

run;

Ask a Question
Discussion stats
  • 1 reply
  • 2988 views
  • 5 likes
  • 2 in conversation