DATA Step, Macro, Functions and more

Assign sequential number by one variable

Accepted Solution Solved
Reply
Contributor
Posts: 23
Accepted Solution

Assign sequential number by one variable

Hi all! I have a question about how to assign a sequential number by one variable.

 

Below is the dataset I'm starting with:

 

id

213

213

413

413

535

535

617

617

 

This is what I would like

id        seq

213      1

213      1

413      2

413      2

535      3

535      3

617      4

617      4

 

Any advice?


Accepted Solutions
Solution
‎06-14-2018 06:37 PM
PROC Star
Posts: 1,772

Re: Assign sequential number by one variable

data want;

set have;

by id;

if first.id then seq+1;

run;

View solution in original post


All Replies
Solution
‎06-14-2018 06:37 PM
PROC Star
Posts: 1,772

Re: Assign sequential number by one variable

data want;

set have;

by id;

if first.id then seq+1;

run;

Contributor
Posts: 23

Re: Assign sequential number by one variable

Posted in reply to novinosrin

Thank you!

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 89 views
  • 1 like
  • 2 in conversation