258.SOAP MARKET ANALYTICS — PROC CONTENTS | PROC PRINT | PROC MEANS | PROC FREQ | PROC SQL | PROC REPORT | PROC SGPLOT | PROC TABULATE IN SAS
- Get link
- X
- Other Apps
SOAP MARKET ANALYTICS — PROC CONTENTS | PROC PRINT | PROC MEANS | PROC FREQ | PROC SQL | PROC REPORT | PROC SGPLOT | PROC TABULATE IN SAS
/* Goal: Creating The Dataset Of Soap Product In India*/
1. Create main dataset
options nocenter;
data soaps;
infile datalines dsd dlm=',' missover;
length Soap_ID 8 Name $40 Brand $25 Type $20 Formulation $15
Scent $20 Color $15 Suitable_Skin $15 Region_Made $20 Returnable $1;
informat Mfg_Date Expiry_Date ddmmyy10.;
format Mfg_Date Expiry_Date date9.;
input Soap_ID Name :$40. Brand :$25. Type :$20. Formulation :$15.
Price Weight_g pH Scent :$20. Color :$15. Suitable_Skin :$15.
Region_Made :$20. Mfg_Date :ddmmyy10. Expiry_Date :ddmmyy10.
Rating Units_Sold_Month Returnable :$1.;
datalines;
1,Navratna Ayurvedic,Navratna,Toilet,Herbal,30,75,7.2,Jasmine,White,All,Kerala,01-01-2024,01-01-2026,4.2,1200,Y
2,GentleCare Liquid,GentleCare,Liquid,Cosmetic,95,250,5.5,Fresh,Lime,Normal,Delhi,15-02-2024,15-02-2026,4.5,800,Y
3,HerbGlow,GloHerb,Toilet,Herbal,40,80,6.8,Aloe,Green,Dry,Goa,01-03-2024,01-03-2026,4.0,950,N
4,Medix Plus,Medix,Syndet,Medicated,85,100,6.2,FragranceFree,Beige,Sensitive,Mumbai,20-02-2024,20-02-2026,4.7,2000,Y
5,SilkTouch,SilkCo,Toilet,Cosmetic,55,100,7.6,Rose,Pink,Normal,Karnataka,05-01-2024,05-01-2026,4.1,700,N
6,AloePure Bar,AloePure,Toilet,Herbal,48,90,6.5,Aloe,LightGreen,Therapeutic,TamilNadu,10-04-2024,10-04-2026,4.3,540,Y
7,GreenEarth Eco,GreenEarth,Toilet,Eco-friendly,65,85,8.0,Herbal,OffWhite,All,Rajasthan,01-05-2024,01-05-2026,3.9,320,Y
8,MountainFresh,HighPeak,Toilet,Cosmetic,70,110,7.4,Pine,White,Normal,UP,12-03-2024,12-03-2026,4.0,410,N
9,GlycerinLux,GlycoLux,Toilet,Glycerin,120,75,7.8,Glycerin,Transparent,Dry,Andhra,01-06-2024,01-06-2026,4.6,260,Y
10,Dettol Original,Reckitt,Toilet,Medicated,40,75,6.6,Medicinal,White,All,Maharashtra,01-07-2024,01-07-2026,4.4,5000,Y
11,HerbalFresh,LotusHerbals,Toilet,Herbal,110,90,6.9,Sandal,Beige,Normal,Kerala,25-05-2024,25-05-2026,4.5,1350,N
12,NeemShield,Neemo,Toilet,Herbal,35,80,6.3,Neem,Green,Sensitive,TamilNadu,10-06-2024,10-06-2026,4.1,880,Y
;
run;
proc print;run;
Output:
Obs | Soap_ID | Name | Brand | Type | Formulation | Scent | Color | Suitable_Skin | Region_Made | Returnable | Mfg_Date | Expiry_Date | Price | Weight_g | pH | Rating | Units_Sold_Month |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 1 | Navratna Ayurvedic | Navratna | Toilet | Herbal | Jasmine | White | All | Kerala | Y | 01JAN2024 | 01JAN2026 | 30 | 75 | 7.2 | 4.2 | 1200 |
2 | 2 | GentleCare Liquid | GentleCare | Liquid | Cosmetic | Fresh | Lime | Normal | Delhi | Y | 15FEB2024 | 15FEB2026 | 95 | 250 | 5.5 | 4.5 | 800 |
3 | 3 | HerbGlow | GloHerb | Toilet | Herbal | Aloe | Green | Dry | Goa | N | 01MAR2024 | 01MAR2026 | 40 | 80 | 6.8 | 4.0 | 950 |
4 | 4 | Medix Plus | Medix | Syndet | Medicated | FragranceFree | Beige | Sensitive | Mumbai | Y | 20FEB2024 | 20FEB2026 | 85 | 100 | 6.2 | 4.7 | 2000 |
5 | 5 | SilkTouch | SilkCo | Toilet | Cosmetic | Rose | Pink | Normal | Karnataka | N | 05JAN2024 | 05JAN2026 | 55 | 100 | 7.6 | 4.1 | 700 |
6 | 6 | AloePure Bar | AloePure | Toilet | Herbal | Aloe | LightGreen | Therapeutic | TamilNadu | Y | 10APR2024 | 10APR2026 | 48 | 90 | 6.5 | 4.3 | 540 |
7 | 7 | GreenEarth Eco | GreenEarth | Toilet | Eco-friendly | Herbal | OffWhite | All | Rajasthan | Y | 01MAY2024 | 01MAY2026 | 65 | 85 | 8.0 | 3.9 | 320 |
8 | 8 | MountainFresh | HighPeak | Toilet | Cosmetic | Pine | White | Normal | UP | N | 12MAR2024 | 12MAR2026 | 70 | 110 | 7.4 | 4.0 | 410 |
9 | 9 | GlycerinLux | GlycoLux | Toilet | Glycerin | Glycerin | Transparent | Dry | Andhra | Y | 01JUN2024 | 01JUN2026 | 120 | 75 | 7.8 | 4.6 | 260 |
10 | 10 | Dettol Original | Reckitt | Toilet | Medicated | Medicinal | White | All | Maharashtra | Y | 01JUL2024 | 01JUL2026 | 40 | 75 | 6.6 | 4.4 | 5000 |
11 | 11 | HerbalFresh | LotusHerbals | Toilet | Herbal | Sandal | Beige | Normal | Kerala | N | 25MAY2024 | 25MAY2026 | 110 | 90 | 6.9 | 4.5 | 1350 |
12 | 12 | NeemShield | Neemo | Toilet | Herbal | Neem | Green | Sensitive | TamilNadu | Y | 10JUN2024 | 10JUN2026 | 35 | 80 | 6.3 | 4.1 | 880 |
2. Utility macro: run common PROCs
%macro basic_checks(ds);
%put NOTE: Running basic data checks for &ds...;
proc contents data=&ds position; title "Variable Attributes - &ds"; run;
proc print data=&ds(obs=5); title "First 5 Obs - &ds"; run;
proc means data=&ds n mean min max maxdec=2;
var Price Weight_g pH Units_Sold_Month Rating;
title "Numeric Summary - &ds";
run;
proc freq data=&ds;
tables Type Formulation Suitable_Skin Region_Made Returnable / nocum;
title "Frequency Tables - &ds";
run;
%mend basic_checks;
%basic_checks(soaps);
Output:
Variable Attributes - soaps
The CONTENTS Procedure
Data Set Name | WORK.SOAPS | Observations | 12 |
---|---|---|---|
Member Type | DATA | Variables | 17 |
Engine | V9 | Indexes | 0 |
Created | 08/11/2025 19:33:36 | Observation Length | 240 |
Last Modified | 08/11/2025 19:33:36 | Deleted Observations | 0 |
Protection | Compressed | NO | |
Data Set Type | Sorted | NO | |
Label | |||
Data Representation | SOLARIS_X86_64, LINUX_X86_64, ALPHA_TRU64, LINUX_IA64 | ||
Encoding | utf-8 Unicode (UTF-8) |
Engine/Host Dependent Information | |
---|---|
Data Set Page Size | 131072 |
Number of Data Set Pages | 1 |
First Data Page | 1 |
Max Obs per Page | 545 |
Obs in First Data Page | 12 |
Number of Data Set Repairs | 0 |
Filename | /saswork/SAS_work9FE400018955_odaws02-apse1-2.oda.sas.com/SAS_workCBFC00018955_odaws02-apse1-2.oda.sas.com/soaps.sas7bdat |
Release Created | 9.0401M8 |
Host Created | Linux |
Inode Number | 959821 |
Access Permission | rw-r--r-- |
Owner Name | u63247146 |
File Size | 256KB |
File Size (bytes) | 262144 |
Alphabetic List of Variables and Attributes | |||||
---|---|---|---|---|---|
# | Variable | Type | Len | Format | Informat |
3 | Brand | Char | 25 | ||
7 | Color | Char | 15 | ||
12 | Expiry_Date | Num | 8 | DATE9. | DDMMYY10. |
5 | Formulation | Char | 15 | ||
11 | Mfg_Date | Num | 8 | DATE9. | DDMMYY10. |
2 | Name | Char | 40 | ||
13 | Price | Num | 8 | ||
16 | Rating | Num | 8 | ||
9 | Region_Made | Char | 20 | ||
10 | Returnable | Char | 1 | ||
6 | Scent | Char | 20 | ||
1 | Soap_ID | Num | 8 | ||
8 | Suitable_Skin | Char | 15 | ||
4 | Type | Char | 20 | ||
17 | Units_Sold_Month | Num | 8 | ||
14 | Weight_g | Num | 8 | ||
15 | pH | Num | 8 |
Variables in Creation Order | |||||
---|---|---|---|---|---|
# | Variable | Type | Len | Format | Informat |
1 | Soap_ID | Num | 8 | ||
2 | Name | Char | 40 | ||
3 | Brand | Char | 25 | ||
4 | Type | Char | 20 | ||
5 | Formulation | Char | 15 | ||
6 | Scent | Char | 20 | ||
7 | Color | Char | 15 | ||
8 | Suitable_Skin | Char | 15 | ||
9 | Region_Made | Char | 20 | ||
10 | Returnable | Char | 1 | ||
11 | Mfg_Date | Num | 8 | DATE9. | DDMMYY10. |
12 | Expiry_Date | Num | 8 | DATE9. | DDMMYY10. |
13 | Price | Num | 8 | ||
14 | Weight_g | Num | 8 | ||
15 | pH | Num | 8 | ||
16 | Rating | Num | 8 | ||
17 | Units_Sold_Month | Num | 8 |
First 5 Obs - soaps
Obs | Soap_ID | Name | Brand | Type | Formulation | Scent | Color | Suitable_Skin | Region_Made | Returnable | Mfg_Date | Expiry_Date | Price | Weight_g | pH | Rating | Units_Sold_Month |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 1 | Navratna Ayurvedic | Navratna | Toilet | Herbal | Jasmine | White | All | Kerala | Y | 01JAN2024 | 01JAN2026 | 30 | 75 | 7.2 | 4.2 | 1200 |
2 | 2 | GentleCare Liquid | GentleCare | Liquid | Cosmetic | Fresh | Lime | Normal | Delhi | Y | 15FEB2024 | 15FEB2026 | 95 | 250 | 5.5 | 4.5 | 800 |
3 | 3 | HerbGlow | GloHerb | Toilet | Herbal | Aloe | Green | Dry | Goa | N | 01MAR2024 | 01MAR2026 | 40 | 80 | 6.8 | 4.0 | 950 |
4 | 4 | Medix Plus | Medix | Syndet | Medicated | FragranceFree | Beige | Sensitive | Mumbai | Y | 20FEB2024 | 20FEB2026 | 85 | 100 | 6.2 | 4.7 | 2000 |
5 | 5 | SilkTouch | SilkCo | Toilet | Cosmetic | Rose | Pink | Normal | Karnataka | N | 05JAN2024 | 05JAN2026 | 55 | 100 | 7.6 | 4.1 | 700 |
Numeric Summary - soaps
The MEANS Procedure
Variable | N | Mean | Minimum | Maximum |
---|---|---|---|---|
Price Weight_g pH Units_Sold_Month Rating | 12 12 12 12 12 | 66.08 100.83 6.90 1200.83 4.28 | 30.00 75.00 5.50 260.00 3.90 | 120.00 250.00 8.00 5000.00 4.70 |
Frequency Tables - soaps
The FREQ Procedure
Type | Frequency | Percent |
---|---|---|
Liquid | 1 | 8.33 |
Syndet | 1 | 8.33 |
Toilet | 10 | 83.33 |
Formulation | Frequency | Percent |
---|---|---|
Cosmetic | 3 | 25.00 |
Eco-friendly | 1 | 8.33 |
Glycerin | 1 | 8.33 |
Herbal | 5 | 41.67 |
Medicated | 2 | 16.67 |
Suitable_Skin | Frequency | Percent |
---|---|---|
All | 3 | 25.00 |
Dry | 2 | 16.67 |
Normal | 4 | 33.33 |
Sensitive | 2 | 16.67 |
Therapeutic | 1 | 8.33 |
Region_Made | Frequency | Percent |
---|---|---|
Andhra | 1 | 8.33 |
Delhi | 1 | 8.33 |
Goa | 1 | 8.33 |
Karnataka | 1 | 8.33 |
Kerala | 2 | 16.67 |
Maharashtra | 1 | 8.33 |
Mumbai | 1 | 8.33 |
Rajasthan | 1 | 8.33 |
TamilNadu | 2 | 16.67 |
UP | 1 | 8.33 |
Returnable | Frequency | Percent |
---|---|---|
N | 4 | 33.33 |
Y | 8 | 66.67 |
3. Analysis macros
%macro summary_by(var);
proc sql;
create table sum_&var as
select &var, count(*) as N, mean(Price) as AvgPrice format=8.2,
sum(Units_Sold_Month) as TotalUnits
from soaps
group by &var
order by TotalUnits desc;
quit;
proc print data=sum_&var; title "Summary by &var"; run;
%mend summary_by;
%macro add_price_band;
data soaps;
set soaps;
length Price_Band $12;
if Price < 60 then Price_Band='Budget';
else if Price < 120 then Price_Band='Mid';
else Price_Band='Premium';
run;
proc print;run;
%mend add_price_band;
%summary_by(Type);
Output:
Summary by Type
Obs | Type | N | AvgPrice | TotalUnits |
---|---|---|---|---|
1 | Toilet | 10 | 61.30 | 11610 |
2 | Syndet | 1 | 85.00 | 2000 |
3 | Liquid | 1 | 95.00 | 800 |
%summary_by(Formulation);
Output:
Summary by Formulation
Obs | Formulation | N | AvgPrice | TotalUnits |
---|---|---|---|---|
1 | Medicated | 2 | 62.50 | 7000 |
2 | Herbal | 5 | 52.60 | 4920 |
3 | Cosmetic | 3 | 73.33 | 1910 |
4 | Eco-friendly | 1 | 65.00 | 320 |
5 | Glycerin | 1 | 120.00 | 260 |
%add_price_band;
Output:
Obs | Soap_ID | Name | Brand | Type | Formulation | Scent | Color | Suitable_Skin | Region_Made | Returnable | Mfg_Date | Expiry_Date | Price | Weight_g | pH | Rating | Units_Sold_Month | Price_Band |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 1 | Navratna Ayurvedic | Navratna | Toilet | Herbal | Jasmine | White | All | Kerala | Y | 01JAN2024 | 01JAN2026 | 30 | 75 | 7.2 | 4.2 | 1200 | Budget |
2 | 2 | GentleCare Liquid | GentleCare | Liquid | Cosmetic | Fresh | Lime | Normal | Delhi | Y | 15FEB2024 | 15FEB2026 | 95 | 250 | 5.5 | 4.5 | 800 | Mid |
3 | 3 | HerbGlow | GloHerb | Toilet | Herbal | Aloe | Green | Dry | Goa | N | 01MAR2024 | 01MAR2026 | 40 | 80 | 6.8 | 4.0 | 950 | Budget |
4 | 4 | Medix Plus | Medix | Syndet | Medicated | FragranceFree | Beige | Sensitive | Mumbai | Y | 20FEB2024 | 20FEB2026 | 85 | 100 | 6.2 | 4.7 | 2000 | Mid |
5 | 5 | SilkTouch | SilkCo | Toilet | Cosmetic | Rose | Pink | Normal | Karnataka | N | 05JAN2024 | 05JAN2026 | 55 | 100 | 7.6 | 4.1 | 700 | Budget |
6 | 6 | AloePure Bar | AloePure | Toilet | Herbal | Aloe | LightGreen | Therapeutic | TamilNadu | Y | 10APR2024 | 10APR2026 | 48 | 90 | 6.5 | 4.3 | 540 | Budget |
7 | 7 | GreenEarth Eco | GreenEarth | Toilet | Eco-friendly | Herbal | OffWhite | All | Rajasthan | Y | 01MAY2024 | 01MAY2026 | 65 | 85 | 8.0 | 3.9 | 320 | Mid |
8 | 8 | MountainFresh | HighPeak | Toilet | Cosmetic | Pine | White | Normal | UP | N | 12MAR2024 | 12MAR2026 | 70 | 110 | 7.4 | 4.0 | 410 | Mid |
9 | 9 | GlycerinLux | GlycoLux | Toilet | Glycerin | Glycerin | Transparent | Dry | Andhra | Y | 01JUN2024 | 01JUN2026 | 120 | 75 | 7.8 | 4.6 | 260 | Premium |
10 | 10 | Dettol Original | Reckitt | Toilet | Medicated | Medicinal | White | All | Maharashtra | Y | 01JUL2024 | 01JUL2026 | 40 | 75 | 6.6 | 4.4 | 5000 | Budget |
11 | 11 | HerbalFresh | LotusHerbals | Toilet | Herbal | Sandal | Beige | Normal | Kerala | N | 25MAY2024 | 25MAY2026 | 110 | 90 | 6.9 | 4.5 | 1350 | Mid |
12 | 12 | NeemShield | Neemo | Toilet | Herbal | Neem | Green | Sensitive | TamilNadu | Y | 10JUN2024 | 10JUN2026 | 35 | 80 | 6.3 | 4.1 | 880 | Budget |
%summary_by(Price_Band);
Output:
Summary by Price_Band
Obs | Price_Band | N | AvgPrice | TotalUnits |
---|---|---|---|---|
1 | Budget | 6 | 41.33 | 9270 |
2 | Mid | 5 | 85.00 | 4880 |
3 | Premium | 1 | 120.00 | 260 |
4. Visual & report outputs
proc sort data=soaps out=soaps_sorted;
by descending Units_Sold_Month;
run;
%let rpt_top_units = 500;
proc report data=soaps_sorted nowd;
columns Name Brand Type Price Units_Sold_Month Rating;
define Units_Sold_Month / analysis sum "Monthly Units";
where Units_Sold_Month >= &rpt_top_units;
title "Top Sellers - Units >= &rpt_top_units";
run;
Output:
Top Sellers - Units >= 500
Name | Brand | Type | Price | Monthly Units | Rating |
---|---|---|---|---|---|
Dettol Original | Reckitt | Toilet | 40 | 5000 | 4.4 |
Medix Plus | Medix | Syndet | 85 | 2000 | 4.7 |
HerbalFresh | LotusHerbals | Toilet | 110 | 1350 | 4.5 |
Navratna Ayurvedic | Navratna | Toilet | 30 | 1200 | 4.2 |
HerbGlow | GloHerb | Toilet | 40 | 950 | 4 |
NeemShield | Neemo | Toilet | 35 | 880 | 4.1 |
GentleCare Liquid | GentleCare | Liquid | 95 | 800 | 4.5 |
SilkTouch | SilkCo | Toilet | 55 | 700 | 4.1 |
AloePure Bar | AloePure | Toilet | 48 | 540 | 4.3 |
proc sgplot data=soaps;
scatter x=Price y=Units_Sold_Month / datalabel=Brand;
reg x=Price y=Units_Sold_Month;
title "Price vs Monthly Sales";
run;
Output:
proc tabulate data=soaps;
class Type Price_Band;
var Units_Sold_Month;
table Type, Price_Band*(Units_Sold_Month*sum);
title "Sales by Type and Price Band";
run;
Output:
Sales by Type and Price Band
Price_Band | |||
---|---|---|---|
Budget | Mid | Premium | |
Units_Sold_Month | Units_Sold_Month | Units_Sold_Month | |
Sum | Sum | Sum | |
Type | . | 800.00 | . |
Liquid | |||
Syndet | . | 2000.00 | . |
Toilet | 9270.00 | 2080.00 | 260.00 |
5. Statistics With Proc Sql
proc sql;
create table brand_perf as
select Brand, mean(Price) as AvgPrice, sum(Units_Sold_Month) as TotalUnits
from soaps
group by Brand;
quit;
proc print data=brand_perf;
run;
Output:
Obs | Brand | AvgPrice | TotalUnits |
---|---|---|---|
1 | AloePure | 48 | 540 |
2 | GentleCare | 95 | 800 |
3 | GloHerb | 40 | 950 |
4 | GlycoLux | 120 | 260 |
5 | GreenEarth | 65 | 320 |
6 | HighPeak | 70 | 410 |
7 | LotusHerbals | 110 | 1350 |
8 | Medix | 85 | 2000 |
9 | Navratna | 30 | 1200 |
10 | Neemo | 35 | 880 |
11 | Reckitt | 40 | 5000 |
12 | SilkCo | 55 | 700 |
- Get link
- X
- Other Apps
Comments
Post a Comment