Okay, I spent some time working on this and found a solution that works for me. I still have some work to do to bring in compounding interest.
CREATE PROCEDURE [dbo].[personalfinanceTest]
@Input_AgeCurrent INT
,@Input_AgeRetire INT
,@Input_Income DECIMAL(10,2)
,@Input_IncomeIncreasePct DECIMAL(10,6)
--@PostTaxSalarySavingsPct decimal(10,2),
----Investment
,@Input_401k_PersonalPct DECIMAL(10,2)
,@Input_401k_EmployerPct DECIMAL(10,2)
,@Input_IRA_TradAmt DECIMAL(10,2)
,@Input_IRA_RothAmt DECIMAL(10,2)
----Market
--@Inflation decimal(10,2),
--@SavingsInterest decimal(10,2)
AS
CREATE TABLE #Table
([Age] INT NOT NULL
,[Years] INT NULL
,[Income] DECIMAL(10,2) NULL
,[401k Personal] DECIMAL(10,2) NULL
,[IRA Traditional] DECIMAL(10,2) NULL
,[Taxable Income] DECIMAL(10,2) NULL
,[Tax] DECIMAL(10,2) NULL
,[PostTax Income] DECIMAL(10,2) NULL
,[Savings] DECIMAL(10,2) NULL
,[401k Employer] DECIMAL(10,2) NULL
,[401k Total] DECIMAL(10,2) NULL
,[IRA Roth] DECIMAL(10,2) NULL
,[IRA Total] DECIMAL(10,2) NULL
,[Cumulative Savings] DECIMAL(10,2) NULL
,[Cumulative Retirement] DECIMAL(10,2) NULL
)
DECLARE @age INT = @Input_AgeCurrent
DECLARE @prev_savings DECIMAL(10,2) = 0
DECLARE @prev_retirement DECIMAL(10,2) = 0
WHILE @age <= @Input_AgeRetire
BEGIN
DECLARE @years INT = @age - @Input_AgeCurrent
DECLARE @income DECIMAL(10,2) = @Input_Income * POWER(@Input_IncomeIncreasePct + 1,@years)
DECLARE @401k_personal DECIMAL(10,2) = @Input_401k_PersonalPct * @income
DECLARE @401k_employer DECIMAL(10,2) = @Input_401k_EmployerPct * @income
DECLARE @tax DECIMAL(10,2) = dbo.calculateTax(@income - @401k_personal)
DECLARE @IRA_trad DECIMAL(10,2) = @Input_IRA_TradAmt
DECLARE @IRA_roth DECIMAL(10,2) = @Input_IRA_RothAmt
DECLARE @income_taxable DECIMAL(10,2) = @income - @401k_personal
DECLARE @income_posttax DECIMAL(10,2) = @income - @tax
DECLARE @401kTotal DECIMAL(10,2) = @401k_personal + @401k_employer
DECLARE @IRATotal DECIMAL(10,2) = @IRA_trad + @IRA_roth
DECLARE @retirement DECIMAL(10,2) = @401kTotal + @IRATotal
DECLARE @savings DECIMAL(10,2) = @income_posttax - @retirement
INSERT INTO #Table([Age]
,[Years]
,[Income]
,[401k Personal]
,[IRA Traditional]
,[Taxable Income]
,[Tax]
,[PostTax Income]
,[Savings]
,[401k Employer]
,[401k Total]
,[IRA Roth]
,[IRA Total]
,[Cumulative Savings]
,[Cumulative Retirement])
SELECT @age
,@years
,@income
,@401k_personal
,@IRA_trad
,@income_taxable
,@tax
,@income_posttax
,@savings
,@401k_employer
,@401kTotal
,@IRA_roth
,@IRATotal
,@prev_savings + @savings
,@prev_retirement + @retirement
SET @age += 1
SET @prev_savings += @savings
SET @prev_retirement += @retirement
END
SELECT *
FROM #Table
Additionally, I created a function for 2016 tax brackets:
CREATE FUNCTION [dbo].[calculateTax] (@salary AS money)
RETURNS money
AS
BEGIN
DECLARE @tax money
DECLARE @10high money = 9275
,@15low money = 9276
,@15high money = 37650
,@25low money = 37651
,@25high money = 91150
,@28low money = 91151
,@28high money = 190150
,@33low money = 190151
,@33high money = 413350
,@35low money = 413351
IF @salary < @10high SET @tax = @salary * 0.1
ELSE IF @salary < @15high SET @tax = @10high * 0.1 + (@salary - @15low)*0.15
ELSE IF @salary < @25high SET @tax = @10high * 0.1 + (@15high - @15low)*0.15 + (@salary - @25low)*0.25
ELSE SET @tax = @10high * 0.1 + (@15high - @15low)*0.15 + (@25high - @25low)*0.25 + (@salary - @35low)*0.35
RETURN @tax
END;