i have 4 columns in my data set 1: todays date 2: ID 3: member_visit 4: target to hit every week
Date ID Member_visit target_to_hit_per_week
19jun2018 1 230 20
19jun2018 2 357 10
19jun2018 3 100 40
19jun2018 4 444 5
19jun2018 5 159 30
19jun2018 6 300 11
what I want add next 16 weekly dates and what the total be if the IDs hit their weekly total
Example:
ID future_date future_total
1 25JUN2018 230+20 = 250
1 02JUL2018 250+20 = 270
1 09JUL2018 270+20 = 290
1 16JUL2018 290+20=310
1 23JUL2018
1
1
1
future_total = member_visit;
do future_date = date + 7 to date + 16 * 7;
future_total + target_to_hit_per_week;
output;
end;
future_total = member_visit;
do future_date = date + 7 to date + 16 * 7;
future_total + target_to_hit_per_week;
output;
end;
I just realize that this is giving me every day of the week but i only want first day of the weeks so that target_to_hit_per_week is added ones a week not daily. or is there a way that it can give it daily but target_to_hit_per_week is only added once a week.
@hk2013 wrote:
I just realize that this is giving me every day of the week but i only want first day of the weeks so that target_to_hit_per_week is added ones a week not daily. or is there a way that it can give it daily but target_to_hit_per_week is only added once a week.
Your example contains only one date, and I assumed that is the state of your dataset. Please post a more realistic example.
intnx is an equivalent
future_total=Member_visit;
do futuredate =intnx('week',date,1)+1 to intnx('week',date,7)+1 by 7;
future_total+target_to_hit_per_week;
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.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.