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.

NOTE: Format $REGFMT 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:

ObsMallTypeRegionActivitiesSeasonDateFootfall
1Urban BazaarNorthern India"Winter fairs & folk theatre" 01JAN1855820
2Weekly HaatEastern India"Weavers' conclaves & kirtans" 01FEB1855760
3Princely/Royal ArcadeWestern India"Spring courtly soirees" 01MAR1855980
4Cantonment ArcadeSouthern India"Colonial concerts & promenades" 01APR1855910
5Caravanserai CourtCentral India"Caravans & storytellers" 01MAY1855700
6Urban BazaarEastern India"Monsoon prep & craft guilds" 01JUN1855650
7Weekly HaatNorthern India"Monsoon haat & folk music" 01JUL1855690
8Princely/Royal ArcadeCentral India"Pre-festival exhibitions" 01AUG1855930
9Cantonment ArcadeWestern India"Ganesh festivities & parades" 01SEP18551050
10Caravanserai CourtSouthern India"Dussehra/Diwali bazaars" 01OCT18551180


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:

ObsMallTypeRegionActivitiesSeasonDateFootfallmonthSeasonalIndexAdjFootfall
1Urban BazaarNorthern India"Winter fairs & folk theatre"Off-Peak01JAN185582010.85697
2Weekly HaatEastern India"Weavers' conclaves & kirtans"Off-Peak01FEB185576020.85646
3Princely/Royal ArcadeWestern India"Spring courtly soirees"Peak01MAR185598031.201176
4Cantonment ArcadeSouthern India"Colonial concerts & promenades"Peak01APR185591041.201092
5Caravanserai CourtCentral India"Caravans & storytellers"Off-Peak01MAY185570050.85595
6Urban BazaarEastern India"Monsoon prep & craft guilds"Off-Peak01JUN185565060.85553
7Weekly HaatNorthern India"Monsoon haat & folk music"Off-Peak01JUL185569070.85587
8Princely/Royal ArcadeCentral India"Pre-festival exhibitions"Off-Peak01AUG185593080.85791
9Cantonment ArcadeWestern India"Ganesh festivities & parades"Peak01SEP1855105091.201260
10Caravanserai CourtSouthern India"Dussehra/Diwali bazaars"Peak01OCT18551180101.201416


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:

ObsDateMallTypeRegionActivitiesFootfallAdjFootfallMA3_OverallMA3_ByType
101JAN1855Urban BazaarNorthern India"Winter fairs & folk theatre"820697697.00697
201FEB1855Weekly HaatEastern India"Weavers' conclaves & kirtans"760646671.50646
301MAR1855Princely/Royal ArcadeWestern India"Spring courtly soirees"9801176839.671176
401APR1855Cantonment ArcadeSouthern India"Colonial concerts & promenades"9101092971.331092
501MAY1855Caravanserai CourtCentral India"Caravans & storytellers"700595954.33595
601JUN1855Urban BazaarEastern India"Monsoon prep & craft guilds"650553746.67553
701JUL1855Weekly HaatNorthern India"Monsoon haat & folk music"690587578.33587
801AUG1855Princely/Royal ArcadeCentral India"Pre-festival exhibitions"930791643.67791
901SEP1855Cantonment ArcadeWestern India"Ganesh festivities & parades"10501260879.331260
1001OCT1855Caravanserai CourtSouthern India"Dussehra/Diwali bazaars"118014161155.671416


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:

ObsDateMallTypeRegionActivitiesFootfallAdjFootfallMA3_OverallMA3_ByType
101JAN1855Urban BazaarNorthern India"Winter fairs & folk theatre"820697697.00697
201JUN1855Urban BazaarEastern India"Monsoon prep & craft guilds"650553746.67553
301APR1855Cantonment ArcadeSouthern India"Colonial concerts & promenades"9101092971.331092
401SEP1855Cantonment ArcadeWestern India"Ganesh festivities & parades"10501260879.331260
501MAY1855Caravanserai CourtCentral India"Caravans & storytellers"700595954.33595
601OCT1855Caravanserai CourtSouthern India"Dussehra/Diwali bazaars"118014161155.671416
701FEB1855Weekly HaatEastern India"Weavers' conclaves & kirtans"760646671.50646
801JUL1855Weekly HaatNorthern India"Monsoon haat & folk music"690587578.33587
901MAR1855Princely/Royal ArcadeWestern India"Spring courtly soirees"9801176839.671176
1001AUG1855Princely/Royal ArcadeCentral India"Pre-festival exhibitions"930791643.67791


%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:

ObsDateMallTypeRegionActivitiesFootfallAdjFootfallMA3_OverallMA3_ByTypelag1_xcumsum_xcount_in_grpq1q2q3diff1pctchgMA3_DataStepCUMSUM
101JAN1855Urban BazaarNorthern India"Winter fairs & folk theatre"820697697.006976976971..697...697
201JUN1855Urban BazaarEastern India"Monsoon prep & craft guilds"650553746.6755355312502.697553-144-20.660.1250
301APR1855Cantonment ArcadeSouthern India"Colonial concerts & promenades"9101092971.331092109210921..1092...1092
401SEP1855Cantonment ArcadeWestern India"Ganesh festivities & parades"10501260879.331260126023522.1092126016815.385.2352
501MAY1855Caravanserai CourtCentral India"Caravans & storytellers"700595954.335955955951..595...595
601OCT1855Caravanserai CourtSouthern India"Dussehra/Diwali bazaars"118014161155.671416141620112.5951416821137.983.2011
701FEB1855Weekly HaatEastern India"Weavers' conclaves & kirtans"760646671.506466466461..646...646
801JUL1855Weekly HaatNorthern India"Monsoon haat & folk music"690587578.3358758712332.646587-59-9.133.1233
901MAR1855Princely/Royal ArcadeWestern India"Spring courtly soirees"9801176839.671176117611761..1176...1176
1001AUG1855Princely/Royal ArcadeCentral India"Pre-festival exhibitions"930791643.6779179119672.1176791-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:

ObsDateMallTypeRegionActivitiesFootfallSeasonSeasonalIndexAdjFootfallMA3_OverallMA3_ByTypediff1pctchgCUMSUMMA3_DataStep
101JAN1855Urban BazaarNorthern India"Winter fairs & folk theatre"820Off-Peak0.85697697.00697..697.
201FEB1855Weekly HaatEastern India"Weavers' conclaves & kirtans"760Off-Peak0.85646671.50646..646.
301MAR1855Princely/Royal ArcadeWestern India"Spring courtly soirees"980Peak1.201176839.671176..1176.
401APR1855Cantonment ArcadeSouthern India"Colonial concerts & promenades"910Peak1.201092971.331092..1092.
501MAY1855Caravanserai CourtCentral India"Caravans & storytellers"700Off-Peak0.85595954.33595..595.
601JUN1855Urban BazaarEastern India"Monsoon prep & craft guilds"650Off-Peak0.85553746.67553-144-20.6601250.
701JUL1855Weekly HaatNorthern India"Monsoon haat & folk music"690Off-Peak0.85587578.33587-59-9.1331233.
801AUG1855Princely/Royal ArcadeCentral India"Pre-festival exhibitions"930Off-Peak0.85791643.67791-385-32.7381967.
901SEP1855Cantonment ArcadeWestern India"Ganesh festivities & parades"1050Peak1.201260879.33126016815.3852352.
1001OCT1855Caravanserai CourtSouthern India"Dussehra/Diwali bazaars"1180Peak1.2014161155.671416821137.9832011.


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:

ObsDateMallTypeRegionActivitiesFootfallSeasonSeasonalIndexAdjFootfallMA3_OverallMA3_ByTypediff1pctchgCUMSUMMA3_DataStep
101JAN1855Urban BazaarNorthern India"Winter fairs & folk theatre"820Off-Peak0.85697697.00697..697.
201FEB1855Weekly HaatEastern India"Weavers' conclaves & kirtans"760Off-Peak0.85646671.50646..646.
301MAR1855Princely/Royal ArcadeWestern India"Spring courtly soirees"980Peak1.201176839.671176..1176.
401APR1855Cantonment ArcadeSouthern India"Colonial concerts & promenades"910Peak1.201092971.331092..1092.
501MAY1855Caravanserai CourtCentral India"Caravans & storytellers"700Off-Peak0.85595954.33595..595.
601JUN1855Urban BazaarEastern India"Monsoon prep & craft guilds"650Off-Peak0.85553746.67553-144-20.6601250.
701JUL1855Weekly HaatNorthern India"Monsoon haat & folk music"690Off-Peak0.85587578.33587-59-9.1331233.
801AUG1855Princely/Royal ArcadeCentral India"Pre-festival exhibitions"930Off-Peak0.85791643.67791-385-32.7381967.
901SEP1855Cantonment ArcadeWestern India"Ganesh festivities & parades"1050Peak1.201260879.33126016815.3852352.
1001OCT1855Caravanserai CourtSouthern India"Dussehra/Diwali bazaars"1180Peak1.2014161155.671416821137.9832011.


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:

The SGPlot Procedure





To Visit My Previous Intermediate Students Performance Dataset:Click Here
To Visit My Previous Namkeen Data Creation:Click Here
To Visit My Previous Hyd_Mall_Family Dataset:Click Here
To Visit My Previous Home Energy Consumption Dataset:Click Here



Follow Us On : 


 


--- FOLLOW OUR BLOG FOR MORE INFORMATION.

--->PLEASE DO COMMENTS AND SHARE OUR BLOG.




Comments

Popular posts from this blog

409.Can We Build a Reliable Emergency Services Analytics & Fraud Detection System in SAS While Identifying and Fixing Intentional Errors?

397.If a satellite has excellent signal strength but very high latency, can it still deliver good quality communication? Why or why not?A Sas Study

401.How Efficient Are Global Data Centers? A Complete SAS Analytics Study