BookmarkSubscribeRSS Feed
prattipati
Calcite | Level 5

Hi ,

 

I got below data and need to Calulate the number days each the status stayed. I need to populate the last two fileds ?

 

I need flag when the status changes and number of days in each status . Please let me know if you need any further infomration . thanks 

 

Code ID Date Status Status Change Flag No of days in each status
55 ABC 25-Jan-12 Y    
29 ABC 22-Mar-12 Y    
56 ABC 05-Jan-13 N    
60 ABC 03-Feb-14 N    
91 ABC 15-May-15 N    
81 ABC 09-Oct-16 Y    
98 ABC 09-Dec-16 Y    
102 ABC 25-Jan-18 Y    
105 ADR 05-Jan-13 N    
125 ADR 09-Oct-16 N    
135 ADR 25-Jan-18 N    
155 ADR 05-May-19 Y    
168 ADR 15-Jun-20    

Thanks

1 REPLY 1
Kurt_Bremser
Super User

For the status change, use the LAG function. For the number of days, keep the first date in a RETAINed variable.

How do you want to calculate the duration (what should be used as the end date)?

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1 reply
  • 248 views
  • 0 likes
  • 2 in conversation