BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
EMC9
Obsidian | Level 7

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
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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;

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

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;
EMC9
Obsidian | Level 7
thank you.

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 774 views
  • 0 likes
  • 2 in conversation