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;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.