Solved
Contributor
Posts: 42

# create date and sum

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

Accepted Solutions
Solution
‎06-19-2018 02:29 PM
Super User
Posts: 10,534

## Re: create date and sum

``````future_total = member_visit;
do future_date = date + 7 to date + 16 * 7;
future_total + target_to_hit_per_week;
output;
end;``````
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

All Replies
Solution
‎06-19-2018 02:29 PM
Super User
Posts: 10,534

## Re: create date and sum

``````future_total = member_visit;
do future_date = date + 7 to date + 16 * 7;
future_total + target_to_hit_per_week;
output;
end;``````
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Contributor
Posts: 42

## Re: create date and sum

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.

Super User
Posts: 10,534

## Re: create date and sum

@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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Posts: 2,049

## Re: create date and sum

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;``````
☑ This topic is solved.