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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.