good day I have a data set below that has user_no (there could be multiple user use_no with different dates)
I want to create a loop that adds a maximum date unitl 201802 for eg:
if the last date for user 123 is 201711 I want the loop the add 201712 / 201801 / 201802
the data looks below : I have not attempted the code :
user_no | month | New_month |
123 | 201505 | 201505 |
123 | 201506 | 201506 |
123 | 201507 | 201507 |
123 | 201508 | 201508 |
123 | 201509 | 201509 |
123 | 201510 | 201510 |
123 | 201511 | 201511 |
123 | 201512 | 201512 |
123 | 201601 | 201601 |
123 | 201602 | 201602 |
123 | 201603 | 201603 |
123 | 201604 | 201604 |
123 | 201605 | 201605 |
123 | 201606 | 201606 |
123 | 201607 | 201607 |
123 | 201608 | |
123 | 201609 | |
123 | 201610 | |
123 | "" | |
123 | "" | |
123 | "" | |
123 | "" | |
123 | "' | |
123 | 201802 |
Do by-group-processing and add this in the data step:
output;
if last.user
then do while (new_month < '201801');
new_month = /* next month to be calculated according to the values; with SAS dates, use the intnx() function */;
output;
end;
Do by-group-processing and add this in the data step:
output;
if last.user
then do while (new_month < '201801');
new_month = /* next month to be calculated according to the values; with SAS dates, use the intnx() function */;
output;
end;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.