BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
OJohn_StaT
Obsidian | Level 7

OJohn_StaT_0-1652960160309.png

This observation above is one of thousands of observations in my dataset. Member name JD25654 has a subscription between these dates. Using this data, I want to make a new dataset like the following dataset. Subscription dates of each member are changing. Some of them have been members for 10 years, some of them have been a member for 1 year. I tried ways like lagging etc, but I couldn't get this dataset I need. Could you help?

 

OJohn_StaT_0-1652961262041.png

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Use a DO loop:

data want;
set have;
do year = year(subscription_start_date) to year(subscription_end_date);
  output;
end;
keep user_id year subscription;
run;

proc sort data=want;
by user_id descending year;
run;

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

Use a DO loop:

data want;
set have;
do year = year(subscription_start_date) to year(subscription_end_date);
  output;
end;
keep user_id year subscription;
run;

proc sort data=want;
by user_id descending year;
run;
OJohn_StaT
Obsidian | Level 7

Thank you so much for your time and your contribution!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

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