BookmarkSubscribeRSS Feed
Singham20
Obsidian | Level 7

Hi!

I am having trouble with applying risk adjustments to my various projects. What I have is 15 Projects that start in the beginning of quarters over the next 3 years. These projects all have a potential earning associated with them. The potential earnings do not change for a project once it starts. For instance Project 1 starts on 1/1/2020 and has a potential earning of 2. This means starting 1/1/2020 and through the end of the timeframe in the data table the earning of Project 1 will be 2 for every month. So for Project 7, which starts on 7/1/2020 and has a potential earning of 1, it will have no earnings from 1/1/2020 to 6/1/2020; however on 7/1/2020 and onwards it will have a potential earning of 1. From here is where the confusion arises for me. We expect that there is a good chance that the potential earnings will not be met so we need to account for that. Regardless of the start date the risk adjustment is as follows:

For first 3 months we will only see 30%. For the next 3 months we will see 60%. For 6+ months since start date we should see 80% of the potential.

1-3 months from start date: (30% * Potential Earnings)

4-6 months from start date: (60% * Potential Earnings)

7+ months from start date: (80% * Potential Earnings)

So for Project 1 which as an earnings potential of 2 and starts in 1/1/2020 I should see the following:

1/1/2020 (2*30%)

2/1/2020 (2*30%)

3/1/2020 (2*30%)

4/1/2020 (2*60%)

5/1/2020 (2*60%)

6/1/2020 (2*60%)

7/1/2020 (2*80%)

9/1/2020 (2*80%)

And so on …

After we get these risk adjustments to all the projects depending on the start data I need to sum it for each month of the year and group the total by the Group variable, which is A or B. Below is a table to see what I am talking about. Hope someone can help me on this SAS Homework!

GroupA or BABAABABBBBBAAAB
ProjectNumberProject 1Project 2Project 3Project 4Project 5Project 6Project 7Project 8Project 9Project 10Project 11Project 12Project 13Project 14Project 15
Project StartDate1/1/20201/1/20201/1/20201/1/20201/1/20207/1/20207/1/20207/1/202010/1/202010/1/20204/1/20214/1/20211/1/20221/1/202210/1/2022
ExpectedEarnings2421322184251234
DateQuarter               
1/1/2020Q124213          
2/1/2020Q124213          
3/1/2020Q124213          
4/1/2020Q224213          
5/1/2020Q224213          
6/1/2020Q224213          
7/1/2020Q3242132218       
8/1/2020Q3242132218       
9/1/2020Q3242132218       
10/1/2020Q424213221842     
11/1/2020Q424213221842     
12/1/2020Q424213221842     
1/1/2021Q124213221842     
2/1/2021Q124213221842     
3/1/2021Q124213221842     
4/1/2021Q22421322184251   
5/1/2021Q22421322184251   
6/1/2021Q22421322184251   
7/1/2021Q32421322184251   
8/1/2021Q32421322184251   
9/1/2021Q32421322184251   
10/1/2021Q42421322184251   
11/1/2021Q42421322184251   
12/1/2021Q42421322184251   
1/1/2022Q1242132218425123 
2/1/2022Q1242132218425123 
3/1/2022Q1242132218425123 
4/1/2022Q2242132218425123 
5/1/2022Q2242132218425123 
6/1/2022Q2242132218425123 
7/1/2022Q3242132218425123 
8/1/2022Q3242132218425123 
9/1/2022Q3242132218425123 
10/1/2022Q42421322184251234
11/1/2022Q42421322184251234
12/1/2022Q42421322184251234
1/1/2023Q12421322184251234
2/1/2023Q12421322184251234
3/1/2023Q12421322184251234
4/1/2023Q22421322184251234
5/1/2023Q22421322184251234
6/1/2023Q22421322184251234
7/1/2023Q32421322184251234
8/1/2023Q32421322184251234
9/1/2023Q32421322184251234
10/1/2023Q42421322184251234
11/1/2023Q42421322184251234
12/1/2023Q42421322184251234

 

2 REPLIES 2
esjackso
Quartz | Level 8

You post the goal but dont actually post what you have tried or where you have an issue in your code. Hard to help with your issue if you dont say what the issue is you have.

 

Eric

Patrick
Opal | Level 21

@Singham20 

First step is to read your source data into a SAS table in a long structure. Below a SAS data step which creates some sample data in such a long structure.

data have_long(drop=_i);
  attrib
    group project length=$8.
    start_dt expected_dt format=ddmmyy10.
    expected_earning format=best32.
    ;
  group='A';
  project='P1';
  start_dt='01jan2020'd;
  expected_earning=2;

  do _i=0 to 47;
    expected_dt=intnx('month',start_dt,_i,'b');
    output;
  end;

  group='B';
  project='P8';
  start_dt='01jul2020'd;
  expected_earning=8;

  do _i=0 to 40;
    expected_dt=intnx('month',start_dt,_i,'b');
    output;
  end;
run;

Once you've got your data organized just compare the start date with the current date in the row and then use the adjustment factor based on the month you're in.

data risk_adjusted;
  set have_long;
  attrib 
    expected_earning_adj format=best32.
    ;
  /* month 7+ */
  if intck('month',start_dt,expected_dt)>=6 then
    expected_earning_adj=expected_earning*0.8;
  /* 4th to 6th month */
  else if intck('month',start_dt,expected_dt) in (3,4,5) then
    expected_earning_adj=expected_earning*0.6;
  /* first 3 months */
  else if intck('month',start_dt,expected_dt) in (0,1,2) then
    expected_earning_adj=expected_earning*0.3;
run;

proc print data=risk_adjusted;
run;

In case it's not clear to you what functions intck() and intnx() are doing, start with reading the docu here.

 

To create the report: Look into Proc Report.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 448 views
  • 0 likes
  • 3 in conversation