SAS Procedures

Help using Base SAS procedures
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.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

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
  • 95656 views
  • 3 likes
  • 6 in conversation