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!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 493 views
  • 1 like
  • 2 in conversation