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

I am trying to create a sequence number to enumerate the total number of visits to a service (I cannot delete duplicates because of other variables). 

I already have a variable that indicates if the client presented unique visits. Therefore, the sequence number should enumerate all visits but keep the same number when any client does not present a unique visit. 

 

I hope you can help me with this since I'm quite new in SAS. Thank you!!

 

IDUnique_visitTotal_visits (NEEDED)
111
112
102
213
214
315
305
316
417
418
408
419

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
data want;
 set have;
 Total_visits +unique_visit;
run;

View solution in original post

3 REPLIES 3
novinosrin
Tourmaline | Level 20
data want;
 set have;
 Total_visits +unique_visit;
run;
Sapt86
Fluorite | Level 6

I cannot believe that I was overthinking this. Thank you so much!!

Reeza
Super User
This requires a RETAIN, which tells SAS to keep the value to the next row. You can explicitly tell SAS to retain the variable but a SUM statement as in novinosrin will add an IMPLICIT retain that will keep the values across the rows. The first variable in the SUM statement is part of the implicit retain.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1884 views
  • 2 likes
  • 3 in conversation