data _NULL_;
call symput('c_dt',input(&currdate_sql,yymmdd10.));
call symput ( 'qtr_start_1', put(intnx('quarter',&c_dt,-1,'b'),date9.));
call symput ( 'qtr_end_1', put(intnx('quarter',&c_dt,-1,'e'),date9.));
call symput ( 'qtr_start_2', put(intnx('quarter',&c_dt,-2,'b'),date9.));
call symput ( 'qtr_end_2', put(intnx('quarter',&c_dt,-2,'e'),date9.));
call symput ( 'qtr_start_3', put(intnx('quarter',&c_dt,-3,'b'),date9.));
call symput ( 'qtr_end_3', put(intnx('quarter',&c_dt,-3,'e'),date9.));
call symput ( 'qtr_start_4', put(intnx('quarter',&c_dt,-4,'b'),date9.));
call symput ( 'qtr_end_4', put(intnx('quarter',&c_dt,-4,'e'),date9.));
run;
data quarters;
set group12;
if datepart(report_dt_p) GE intnx('month', "&trend_end."d /*&trend_end.*/, -2) then Q1_count=count;
else Q1_count=0;
if datepart(report_dt_p) GE intnx('month', "&trend_end."d /*&trend_end.*/, -5) and datepart(report_dt_p)
LT intnx('month',"&trend_end."d /*&trend_end.*/, -2) then Q2_count=count; else Q2_count=0;
if datepart(report_dt_p) GE intnx('month', "&trend_end."d /*&trend_end.*/, -8) and datepart(report_dt_p)
LT intnx('month', "&trend_end."d /*&trend_end.*/, -5) then Q3_count=count;else Q3_count=0;
if datepart(report_dt_p) LT intnx('month', "&trend_end."d /*&trend_end.*/, -8) then Q4_count=count;
else Q4_count=0;
if quarter='Q1' then Q1_count=count; else Q1_count=0;
if quarter='Q2' then Q2_count=count; else Q2_count=0;
if quarter='Q3' then Q3_count=count; else Q3_count=0;
if quarter='Q4' then Q4_count=count; else Q4_count=0;
run;
sample data
Q1_count
Q2_count
Q3_count
Q4_count
0
1
2
1
6
19
9
81
3
5
0
1
10
9
0
0
1
6
5
2
Here is my question. Is there a way to assign the various Q counts a header based on the quarter. For example Q1_Count becomes Q1_Count_”&qtr_start_1” ||&qtr_end_1” or Q1_count_1jul2015-30Sep2015
... View more