Code - Retail Analysis - Sas
Code - Retail Analysis - Sas
/* OR */
/* OR */
/* Filter year(2012) */
data date_12;
set work.walmart;
where year(date)=2012;
run;
data growth;
format growth_rate percent8.2;
set work.date_12;
by store date weekly_sales;
lag_sales = ifn(first.store,0,lag(weekly_sales));
growth_rate = (weekly_sales/lag_sales)-1;
drop lag_sales;
run;
data good_growth_rate;
set good_growth;
where qtr(date)= 3;
run;
/* Now Sort the data to see the good growth rate store wise */
data holiday;
set work.walmart;
where holiday_flag=1;
run;
data non_holiday;
set work.walmart;
where holiday_flag=0;
run;
proc print data=non_holiday;
run;
/* Compare the mean weekly_sales of the non-holiday data with weekly_sales of the holiday data */
proc sql;
create table holiday_sales as
select store, weekly_sales, date, holiday_flag as holiday,
case
when weekly_sales > 1041256.38 then 'Higher'
when weekly_sales < 1041256.38 then 'Lower'
end
as higher_sales
from holiday;
quit;
data higher_holiday_sales;
set work.holiday_sales;
where higher_sales = 'Higher';
drop higher_sales;
title 'Higher Sales during Holidays';
run;
/* Provide a monthly and semester view of sales in units and give insights */
/* Giving insights */
/* 1. Doing Comparison */
/* a) Bar Chart */
data date;
set work.monthly_sales;
month = month(Date);
month_name=PUT(Date,monname.);
put month_name= @;
run;
/* 2) Studying relationship */
/* a) Bubble Chart */
/* 3. Studying Distribution */
/* a) Histogram */
/* b) Scatter Plot */
/* 4) Composition */
/* Giving insights */
/* 1. Doing Comparison */
/* a) Bar Chart */
data date;
set work.semester_sales;
month = month(Date);
month_name=PUT(Date,monname.);
put month_name= @;
run;
/* 2) Studying relationship */
/* a) Bubble Chart */
/* 3. Studying Distribution */
/* a) Histogram */
/* b) Scatter Plot */
/* 4) Composition */
/* Store-1 data */
data store1;
set work.walmart;
where store = 1;
run;
/* Build Model */
ods noproctitle;
ods graphics / imagemap=on;