BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tusher
Calcite | Level 5

To Solop (and others), 

Although it's a  late solution to this specific problem, yet there is a simple solution indeed. First sort the dataset using the sequence variable as your key variable. (not shown in the code).

Let's say your sequence variable is exseq. Then, before your SET statement use a RETAIN statement and use the seq variable as the statement's option.

 

data EX;
retain exseq ; * must retain this variable in order to re-start assigning a new sequence number;
set ex1;
by subject;
if first.subject then exseq = 0;
exseq+1; * this will assign sequential values to exseq variable;
keep subject exseq;  * optional!; 
run;

 

Hiope this helps.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 15 replies
  • 97850 views
  • 3 likes
  • 6 in conversation