proc sql;
select distinct
month(A.Month_End),
A.Month_End,
A.RTAM_ID,
Year(A.Month_End),
&fyear.,
&fy_prev.,
SUM(case when product=66 then value else 0 end) as MTRC_DOL_VAL1, /*cl_Promoters*/
SUM(case when product=67 then value else 0 end) as MTRC_DOL_VAL2, /*cl_Detractors*/
SUM(case when product=25 then value else 0 end) as MTRC_DOL_VAL3, /*cl_Responses*/
sum((case when month(A.Month_End) = 10 and Year(A.Month_End) = &fy_prev. and product=25 then A.Value)
sum(when month(A.Month_End) = 11 and month(A.Month_End) IN (10,11) and Year(A.Month_End) = &fy_prev. and product=25 then A.Value)
SUM(when month(A.Month_End) = 12 and month(A.Month_End) IN (10,11,12) and Year(A.Month_End) = &fy_prev. and product=25 then A.Value)
SUM(when month(A.Month_End) = 1 and month(A.Month_End) IN (10,11,12,1) and Year(A.Month_End) = &fy_prev. and product=25 then A.Value)
else 0 end) as MTR1
from
(SELECT distinct
t1.date,
input(t1.date, yymmdd10.) format date9. as Month_End,
t1.transit as Transit,
(t1.transit*1000) + t1.am as RTAM_ID,
2000 as MTRC_ID,
'NPS' as MTRC_NM,
. as Month_IN_YEAR,
. as fiscal_mth_of_year,
. as mth_num,
t1.value,
t1.product
FROM nps.nps_master_&descdt. as t1
where t1.product in (25,66,67)) as A
Group by 1,2,3
order by A.Month_End
;
quit; Hi, I am new to SAS and trying to solve the issue of running totals between multiple years. For example, if the Month 11 value is 2 and Month 12 value 2 I want to sum in the Month 12 value = 4 Any help would be appreciated.
... View more