303.Did Seasons Control Market Activity and Temple Footfall in 1855 India?A Sas Study
Did Seasons Control Market Activity and Temple Footfall in 1855 India?A Sas Study
options nodate nonumber nocenter;
1) FORMATS
proc format;
value $mallfmt
'Bazaar' = 'Urban Bazaar'
'Haat' = 'Weekly Haat'
'RoyalArcade' = 'Princely/Royal Arcade'
'CantonmentMall' = 'Cantonment Arcade'
'CaravanseraiCourt' = 'Caravanserai Court';
value $regfmt
'North' = 'Northern India'
'East' = 'Eastern India'
'West' = 'Western India'
'South' = 'Southern India'
'Central' = 'Central India';
run;
LOG:
NOTE: Format $MALLFMT has been output.
2) BASE DATA
data hist_mall_1855_base;
length MallType $20 Region $10 Activities $50 Season $8;
input Date :yymmdd10. MallType :$20. Region :$10. Activities :& $50.
Footfall;
format Date date9.
MallType $mallfmt.
Region $regfmt.;
datalines;
1855-01-01 Bazaar North "Winter fairs & folk theatre" 820
1855-02-01 Haat East "Weavers' conclaves & kirtans" 760
1855-03-01 RoyalArcade West "Spring courtly soirees" 980
1855-04-01 CantonmentMall South "Colonial concerts & promenades" 910
1855-05-01 CaravanseraiCourt Central "Caravans & storytellers" 700
1855-06-01 Bazaar East "Monsoon prep & craft guilds" 650
1855-07-01 Haat North "Monsoon haat & folk music" 690
1855-08-01 RoyalArcade Central "Pre-festival exhibitions" 930
1855-09-01 CantonmentMall West "Ganesh festivities & parades" 1050
1855-10-01 CaravanseraiCourt South "Dussehra/Diwali bazaars" 1180
;
run;
proc print data=hist_mall_1855_base;
run;
OUTPUT:
| Obs | MallType | Region | Activities | Season | Date | Footfall |
|---|---|---|---|---|---|---|
| 1 | Urban Bazaar | Northern India | "Winter fairs & folk theatre" | 01JAN1855 | 820 | |
| 2 | Weekly Haat | Eastern India | "Weavers' conclaves & kirtans" | 01FEB1855 | 760 | |
| 3 | Princely/Royal Arcade | Western India | "Spring courtly soirees" | 01MAR1855 | 980 | |
| 4 | Cantonment Arcade | Southern India | "Colonial concerts & promenades" | 01APR1855 | 910 | |
| 5 | Caravanserai Court | Central India | "Caravans & storytellers" | 01MAY1855 | 700 | |
| 6 | Urban Bazaar | Eastern India | "Monsoon prep & craft guilds" | 01JUN1855 | 650 | |
| 7 | Weekly Haat | Northern India | "Monsoon haat & folk music" | 01JUL1855 | 690 | |
| 8 | Princely/Royal Arcade | Central India | "Pre-festival exhibitions" | 01AUG1855 | 930 | |
| 9 | Cantonment Arcade | Western India | "Ganesh festivities & parades" | 01SEP1855 | 1050 | |
| 10 | Caravanserai Court | Southern India | "Dussehra/Diwali bazaars" | 01OCT1855 | 1180 |
3) SEASONAL DERIVATION (DATA step)
data hist_mall_1855;
set hist_mall_1855_base;
length Season $8;
month = month(Date);
if month in (3,4,9,10,11) then Season = 'Peak';
else Season = 'Off-Peak';
if Season='Peak' then SeasonalIndex = 1.20;
else SeasonalIndex = 0.85;
AdjFootfall = round(Footfall * SeasonalIndex, 1);
run;
proc print data=hist_mall_1855;
run;
OUTPUT:
| Obs | MallType | Region | Activities | Season | Date | Footfall | month | SeasonalIndex | AdjFootfall |
|---|---|---|---|---|---|---|---|---|---|
| 1 | Urban Bazaar | Northern India | "Winter fairs & folk theatre" | Off-Peak | 01JAN1855 | 820 | 1 | 0.85 | 697 |
| 2 | Weekly Haat | Eastern India | "Weavers' conclaves & kirtans" | Off-Peak | 01FEB1855 | 760 | 2 | 0.85 | 646 |
| 3 | Princely/Royal Arcade | Western India | "Spring courtly soirees" | Peak | 01MAR1855 | 980 | 3 | 1.20 | 1176 |
| 4 | Cantonment Arcade | Southern India | "Colonial concerts & promenades" | Peak | 01APR1855 | 910 | 4 | 1.20 | 1092 |
| 5 | Caravanserai Court | Central India | "Caravans & storytellers" | Off-Peak | 01MAY1855 | 700 | 5 | 0.85 | 595 |
| 6 | Urban Bazaar | Eastern India | "Monsoon prep & craft guilds" | Off-Peak | 01JUN1855 | 650 | 6 | 0.85 | 553 |
| 7 | Weekly Haat | Northern India | "Monsoon haat & folk music" | Off-Peak | 01JUL1855 | 690 | 7 | 0.85 | 587 |
| 8 | Princely/Royal Arcade | Central India | "Pre-festival exhibitions" | Off-Peak | 01AUG1855 | 930 | 8 | 0.85 | 791 |
| 9 | Cantonment Arcade | Western India | "Ganesh festivities & parades" | Peak | 01SEP1855 | 1050 | 9 | 1.20 | 1260 |
| 10 | Caravanserai Court | Southern India | "Dussehra/Diwali bazaars" | Peak | 01OCT1855 | 1180 | 10 | 1.20 | 1416 |
4) MOVING AVERAGES WITH PROC SQL
/* MA3 OVERALL (3-row rolling average by date) */
/* AND MA3 BY MALLTYPE */
proc sql;
create table hist_sql_ma as
select
a.Date,
a.MallType,
a.Region,
a.Activities,
a.Footfall,
a.AdjFootfall,
/* ---- OVERALL MA3 ---- */
( select mean(d.AdjFootfall)
from hist_mall_1855 d
where d.Date between intnx('month', a.Date, -2, 'same')
and a.Date
) as MA3_Overall,
/* ---- MA3 BY MallType ---- */
( select mean(e.AdjFootfall)
from hist_mall_1855 e
where e.MallType = a.MallType
and e.Date between intnx('month', a.Date, -2, 'same')
and a.Date
) as MA3_ByType
from hist_mall_1855 a
order by Date, MallType;
quit;
proc print data=hist_sql_ma;
run;
OUTPUT:
| Obs | Date | MallType | Region | Activities | Footfall | AdjFootfall | MA3_Overall | MA3_ByType |
|---|---|---|---|---|---|---|---|---|
| 1 | 01JAN1855 | Urban Bazaar | Northern India | "Winter fairs & folk theatre" | 820 | 697 | 697.00 | 697 |
| 2 | 01FEB1855 | Weekly Haat | Eastern India | "Weavers' conclaves & kirtans" | 760 | 646 | 671.50 | 646 |
| 3 | 01MAR1855 | Princely/Royal Arcade | Western India | "Spring courtly soirees" | 980 | 1176 | 839.67 | 1176 |
| 4 | 01APR1855 | Cantonment Arcade | Southern India | "Colonial concerts & promenades" | 910 | 1092 | 971.33 | 1092 |
| 5 | 01MAY1855 | Caravanserai Court | Central India | "Caravans & storytellers" | 700 | 595 | 954.33 | 595 |
| 6 | 01JUN1855 | Urban Bazaar | Eastern India | "Monsoon prep & craft guilds" | 650 | 553 | 746.67 | 553 |
| 7 | 01JUL1855 | Weekly Haat | Northern India | "Monsoon haat & folk music" | 690 | 587 | 578.33 | 587 |
| 8 | 01AUG1855 | Princely/Royal Arcade | Central India | "Pre-festival exhibitions" | 930 | 791 | 643.67 | 791 |
| 9 | 01SEP1855 | Cantonment Arcade | Western India | "Ganesh festivities & parades" | 1050 | 1260 | 879.33 | 1260 |
| 10 | 01OCT1855 | Caravanserai Court | Southern India | "Dussehra/Diwali bazaars" | 1180 | 1416 | 1155.67 | 1416 |
5) PROC EXPAND-LIKE TRANSFORMS VIA PURE DATA STEP
proc sort data=hist_sql_ma out=hist_sorted;
by MallType Date;
run;
proc print data=hist_sorted;
run;
OUTPUT:
| Obs | Date | MallType | Region | Activities | Footfall | AdjFootfall | MA3_Overall | MA3_ByType |
|---|---|---|---|---|---|---|---|---|
| 1 | 01JAN1855 | Urban Bazaar | Northern India | "Winter fairs & folk theatre" | 820 | 697 | 697.00 | 697 |
| 2 | 01JUN1855 | Urban Bazaar | Eastern India | "Monsoon prep & craft guilds" | 650 | 553 | 746.67 | 553 |
| 3 | 01APR1855 | Cantonment Arcade | Southern India | "Colonial concerts & promenades" | 910 | 1092 | 971.33 | 1092 |
| 4 | 01SEP1855 | Cantonment Arcade | Western India | "Ganesh festivities & parades" | 1050 | 1260 | 879.33 | 1260 |
| 5 | 01MAY1855 | Caravanserai Court | Central India | "Caravans & storytellers" | 700 | 595 | 954.33 | 595 |
| 6 | 01OCT1855 | Caravanserai Court | Southern India | "Dussehra/Diwali bazaars" | 1180 | 1416 | 1155.67 | 1416 |
| 7 | 01FEB1855 | Weekly Haat | Eastern India | "Weavers' conclaves & kirtans" | 760 | 646 | 671.50 | 646 |
| 8 | 01JUL1855 | Weekly Haat | Northern India | "Monsoon haat & folk music" | 690 | 587 | 578.33 | 587 |
| 9 | 01MAR1855 | Princely/Royal Arcade | Western India | "Spring courtly soirees" | 980 | 1176 | 839.67 | 1176 |
| 10 | 01AUG1855 | Princely/Royal Arcade | Central India | "Pre-festival exhibitions" | 930 | 791 | 643.67 | 791 |
%macro rolling_transforms(ds_in=, ds_out=, groupvar=MallType, datevar=Date,
x=AdjFootfall, window=3);
data &ds_out;
set &ds_in;
by &groupvar &datevar;
retain lag1_x cumsum_x count_in_grp
q1 q2 q3
;
if first.&groupvar then do;
lag1_x=.;
cumsum_x=0;
count_in_grp=0;
q1=.; q2=.; q3=.;
end;
lag1_x = lag1_x;
diff1 = .;
pctchg = .;
count_in_grp + 1;
cumsum_x + &x;
if count_in_grp=1 then do;
diff1 = .;
pctchg = .;
end;
else do;
diff1 = &x - lag1_x;
if lag1_x ne 0 then pctchg = 100 * (&x - lag1_x) / lag1_x;
else pctchg = .;
end;
q1=q2; q2=q3; q3=&x;
if count_in_grp>=&window then MA3_DataStep = mean(of q1-q3);
else MA3_DataStep = .;
lag1_x = &x;
CUMSUM = cumsum_x;
run;
proc print data=&ds_out;run;
%mend rolling_transforms;
%rolling_transforms(ds_in=hist_sorted, ds_out=hist_expand_like,
groupvar=MallType, datevar=Date, x=AdjFootfall, window=3);
OUTPUT:
| Obs | Date | MallType | Region | Activities | Footfall | AdjFootfall | MA3_Overall | MA3_ByType | lag1_x | cumsum_x | count_in_grp | q1 | q2 | q3 | diff1 | pctchg | MA3_DataStep | CUMSUM |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 01JAN1855 | Urban Bazaar | Northern India | "Winter fairs & folk theatre" | 820 | 697 | 697.00 | 697 | 697 | 697 | 1 | . | . | 697 | . | . | . | 697 |
| 2 | 01JUN1855 | Urban Bazaar | Eastern India | "Monsoon prep & craft guilds" | 650 | 553 | 746.67 | 553 | 553 | 1250 | 2 | . | 697 | 553 | -144 | -20.660 | . | 1250 |
| 3 | 01APR1855 | Cantonment Arcade | Southern India | "Colonial concerts & promenades" | 910 | 1092 | 971.33 | 1092 | 1092 | 1092 | 1 | . | . | 1092 | . | . | . | 1092 |
| 4 | 01SEP1855 | Cantonment Arcade | Western India | "Ganesh festivities & parades" | 1050 | 1260 | 879.33 | 1260 | 1260 | 2352 | 2 | . | 1092 | 1260 | 168 | 15.385 | . | 2352 |
| 5 | 01MAY1855 | Caravanserai Court | Central India | "Caravans & storytellers" | 700 | 595 | 954.33 | 595 | 595 | 595 | 1 | . | . | 595 | . | . | . | 595 |
| 6 | 01OCT1855 | Caravanserai Court | Southern India | "Dussehra/Diwali bazaars" | 1180 | 1416 | 1155.67 | 1416 | 1416 | 2011 | 2 | . | 595 | 1416 | 821 | 137.983 | . | 2011 |
| 7 | 01FEB1855 | Weekly Haat | Eastern India | "Weavers' conclaves & kirtans" | 760 | 646 | 671.50 | 646 | 646 | 646 | 1 | . | . | 646 | . | . | . | 646 |
| 8 | 01JUL1855 | Weekly Haat | Northern India | "Monsoon haat & folk music" | 690 | 587 | 578.33 | 587 | 587 | 1233 | 2 | . | 646 | 587 | -59 | -9.133 | . | 1233 |
| 9 | 01MAR1855 | Princely/Royal Arcade | Western India | "Spring courtly soirees" | 980 | 1176 | 839.67 | 1176 | 1176 | 1176 | 1 | . | . | 1176 | . | . | . | 1176 |
| 10 | 01AUG1855 | Princely/Royal Arcade | Central India | "Pre-festival exhibitions" | 930 | 791 | 643.67 | 791 | 791 | 1967 | 2 | . | 1176 | 791 | -385 | -32.738 | . | 1967 |
6) FINAL VIEW: merge SQL MAs and DATA step transforms
proc sql;
create table hist_final as
select a.Date, a.MallType, a.Region, a.Activities, a.Footfall, a.Season,
a.SeasonalIndex, a.AdjFootfall,
b.MA3_Overall, b.MA3_ByType,
c.diff1, c.pctchg, c.CUMSUM, c.MA3_DataStep
from hist_mall_1855 as a
left join hist_sql_ma as b
on a.Date=b.Date and a.MallType=b.MallType
left join hist_expand_like as c
on a.Date=c.Date and a.MallType=c.MallType
order by Date, MallType;
quit;
proc print data=hist_final;
run;
OUTPUT:
| Obs | Date | MallType | Region | Activities | Footfall | Season | SeasonalIndex | AdjFootfall | MA3_Overall | MA3_ByType | diff1 | pctchg | CUMSUM | MA3_DataStep |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 01JAN1855 | Urban Bazaar | Northern India | "Winter fairs & folk theatre" | 820 | Off-Peak | 0.85 | 697 | 697.00 | 697 | . | . | 697 | . |
| 2 | 01FEB1855 | Weekly Haat | Eastern India | "Weavers' conclaves & kirtans" | 760 | Off-Peak | 0.85 | 646 | 671.50 | 646 | . | . | 646 | . |
| 3 | 01MAR1855 | Princely/Royal Arcade | Western India | "Spring courtly soirees" | 980 | Peak | 1.20 | 1176 | 839.67 | 1176 | . | . | 1176 | . |
| 4 | 01APR1855 | Cantonment Arcade | Southern India | "Colonial concerts & promenades" | 910 | Peak | 1.20 | 1092 | 971.33 | 1092 | . | . | 1092 | . |
| 5 | 01MAY1855 | Caravanserai Court | Central India | "Caravans & storytellers" | 700 | Off-Peak | 0.85 | 595 | 954.33 | 595 | . | . | 595 | . |
| 6 | 01JUN1855 | Urban Bazaar | Eastern India | "Monsoon prep & craft guilds" | 650 | Off-Peak | 0.85 | 553 | 746.67 | 553 | -144 | -20.660 | 1250 | . |
| 7 | 01JUL1855 | Weekly Haat | Northern India | "Monsoon haat & folk music" | 690 | Off-Peak | 0.85 | 587 | 578.33 | 587 | -59 | -9.133 | 1233 | . |
| 8 | 01AUG1855 | Princely/Royal Arcade | Central India | "Pre-festival exhibitions" | 930 | Off-Peak | 0.85 | 791 | 643.67 | 791 | -385 | -32.738 | 1967 | . |
| 9 | 01SEP1855 | Cantonment Arcade | Western India | "Ganesh festivities & parades" | 1050 | Peak | 1.20 | 1260 | 879.33 | 1260 | 168 | 15.385 | 2352 | . |
| 10 | 01OCT1855 | Caravanserai Court | Southern India | "Dussehra/Diwali bazaars" | 1180 | Peak | 1.20 | 1416 | 1155.67 | 1416 | 821 | 137.983 | 2011 | . |
7) PLOT: Time-series footfall (Adjusted) grouped by type
proc sort data=hist_final out=plotdata;
by Date MallType;
run;
proc print data=plotdata;
run;
OUTPUT:
| Obs | Date | MallType | Region | Activities | Footfall | Season | SeasonalIndex | AdjFootfall | MA3_Overall | MA3_ByType | diff1 | pctchg | CUMSUM | MA3_DataStep |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 01JAN1855 | Urban Bazaar | Northern India | "Winter fairs & folk theatre" | 820 | Off-Peak | 0.85 | 697 | 697.00 | 697 | . | . | 697 | . |
| 2 | 01FEB1855 | Weekly Haat | Eastern India | "Weavers' conclaves & kirtans" | 760 | Off-Peak | 0.85 | 646 | 671.50 | 646 | . | . | 646 | . |
| 3 | 01MAR1855 | Princely/Royal Arcade | Western India | "Spring courtly soirees" | 980 | Peak | 1.20 | 1176 | 839.67 | 1176 | . | . | 1176 | . |
| 4 | 01APR1855 | Cantonment Arcade | Southern India | "Colonial concerts & promenades" | 910 | Peak | 1.20 | 1092 | 971.33 | 1092 | . | . | 1092 | . |
| 5 | 01MAY1855 | Caravanserai Court | Central India | "Caravans & storytellers" | 700 | Off-Peak | 0.85 | 595 | 954.33 | 595 | . | . | 595 | . |
| 6 | 01JUN1855 | Urban Bazaar | Eastern India | "Monsoon prep & craft guilds" | 650 | Off-Peak | 0.85 | 553 | 746.67 | 553 | -144 | -20.660 | 1250 | . |
| 7 | 01JUL1855 | Weekly Haat | Northern India | "Monsoon haat & folk music" | 690 | Off-Peak | 0.85 | 587 | 578.33 | 587 | -59 | -9.133 | 1233 | . |
| 8 | 01AUG1855 | Princely/Royal Arcade | Central India | "Pre-festival exhibitions" | 930 | Off-Peak | 0.85 | 791 | 643.67 | 791 | -385 | -32.738 | 1967 | . |
| 9 | 01SEP1855 | Cantonment Arcade | Western India | "Ganesh festivities & parades" | 1050 | Peak | 1.20 | 1260 | 879.33 | 1260 | 168 | 15.385 | 2352 | . |
| 10 | 01OCT1855 | Caravanserai Court | Southern India | "Dussehra/Diwali bazaars" | 1180 | Peak | 1.20 | 1416 | 1155.67 | 1416 | 821 | 137.983 | 2011 | . |
title1 "Cultural Footfall in Historic Indian Market Spaces — 1855";
title2 "Adjusted Footfall by Market ('Mall') Type with Seasonal Effects";
proc sgplot data=plotdata;
series x=Date y=AdjFootfall / group=MallType markers;
xaxis label="Month in 1855" grid;
yaxis label="Adjusted Footfall (Seasonally Adjusted)" grid;
run;
title; footnote;
OUTPUT:
Comments
Post a Comment