Right now I have a list of subscribers to a product. Each subscriber has two fields indicating an effective and term date (named date_eff and date_term), such as 01JUL2003 and 31JAN2004. I would like to create a variable that is Month_Paid for each month in that range, so instead of having one row for that subscriber, I would now have 7 rows with the Month_Paid field being 01JUL2003, 01AUG2003, …, 01DEC2003, 01JAN2004.
I've tried a few do loops that I read about on the forum but can't seem to find the correct logic.
Thanks!
I used the follow code:
data want_month;
set spanMOC;
date=dateeff;
do while (date<=dateterm);
output;
date=intnx('month', date, 1, 's');
end;
run;
This code will create the 7 rows I am looking for, the problem is that I cant figure out the concise way to create the new column that gives the month and in the format I described in the original post.
That worked, I had messed up a variable in the loop which was causing the code to run indefinitely. Fixed that and formatted the month field.
Thanks!
try the INTGET
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.