206.ANALYZING BANANA VARIETIES PRODUCTION PRICE REGIONS HEALTH BENEFITS WEIGHT USING PROC MEANS | PROC SQL | PROC MACRO | PROC FREQ | PROC SORT | PROC FORMAT | IN SAS FOR ADVANCED AGRICULTURAL DATA INSIGHTS AND DECISION MAKING
- Get link
- X
- Other Apps
ANALYZING BANANA VARIETIES PRODUCTION PRICE REGIONS HEALTH BENEFITS WEIGHT USING PROC MEANS | PROC SQL | PROC MACRO | PROC FREQ | PROC SORT | PROC FORMAT | IN SAS FOR ADVANCED AGRICULTURAL DATA INSIGHTS AND DECISION MAKING
/*A unique dataset about different types of bananas*/
Step 1: Creating the Dataset
data Banana_Types;
length Banana_ID 8 Variety $20 Origin $15 Color $10 Health_Benefit $30;
infile datalines dsd dlm="" truncover;
input Banana_ID Variety $ Origin $ Color $ Avg_Weight_grams
Price_Per_Kg_USD Production_Tonnes_per_Year Health_Benefit :$&30.;
datalines;
1 Cavendish India Yellow 120 0.45 900000 "Rich in Potassium"
2 Nendran Kerala Yellow 150 0.60 500000 "Aids Digestion"
3 Robusta TamilNadu Green 130 0.40 700000 "Energy Booster"
4 Rasthali Karnataka Yellow 100 0.70 300000 "Good for Skin"
5 Poovan Andhra White 90 0.35 200000 "Iron Rich"
6 Red_Banana Maharashtra Red 160 1.20 150000 "High Antioxidants"
7 Yelakki Karnataka Yellow 80 0.50 120000 "Kid-Friendly"
8 Monthan TamilNadu Green 180 0.55 250000 "Fiber Rich"
9 Karpooravalli Kerala Yellow 140 0.65 300000 "Soothes Ulcers"
10 Saba Philippines Green 200 0.80 800000 "Good for Heart"
11 Manzano Ecuador Yellow 100 0.95 100000 "Apple Taste"
12 Lady_Finger Australia Yellow 85 1.10 75000 "Low Calorie"
13 Blue_Java Hawaii Blue 120 1.50 50000 "Ice Cream Flavor"
14 Plantain Africa Green 300 0.70 600000 "Starch Rich"
15 Mysore_Banana TamilNadu Yellow 95 0.60 250000 "Helps Digestion"
16 "Pisang Raja" Indonesia Yellow 110 0.85 200000 "Vitamin C Source"
17 Praying_Hands Thailand Yellow 200 1.00 180000 "Symbolic Fruit"
;
run;
proc print;run;
Output:
Obs | Banana_ID | Variety | Origin | Color | Health_Benefit | Avg_Weight_grams | Price_Per_Kg_USD | Production_Tonnes_per_Year |
---|---|---|---|---|---|---|---|---|
1 | 1 | Cavendish | India | Yellow | Rich in Potassium | 120 | 0.45 | 900000 |
2 | 2 | Nendran | Kerala | Yellow | Aids Digestion | 150 | 0.60 | 500000 |
3 | 3 | Robusta | TamilNadu | Green | Energy Booster | 130 | 0.40 | 700000 |
4 | 4 | Rasthali | Karnataka | Yellow | Good for Skin | 100 | 0.70 | 300000 |
5 | 5 | Poovan | Andhra | White | Iron Rich | 90 | 0.35 | 200000 |
6 | 6 | Red_Banana | Maharashtra | Red | High Antioxidants | 160 | 1.20 | 150000 |
7 | 7 | Yelakki | Karnataka | Yellow | Kid-Friendly | 80 | 0.50 | 120000 |
8 | 8 | Monthan | TamilNadu | Green | Fiber Rich | 180 | 0.55 | 250000 |
9 | 9 | Karpooravalli | Kerala | Yellow | Soothes Ulcers | 140 | 0.65 | 300000 |
10 | 10 | Saba | Philippines | Green | Good for Heart | 200 | 0.80 | 800000 |
11 | 11 | Manzano | Ecuador | Yellow | Apple Taste | 100 | 0.95 | 100000 |
12 | 12 | Lady_Finger | Australia | Yellow | Low Calorie | 85 | 1.10 | 75000 |
13 | 13 | Blue_Java | Hawaii | Blue | Ice Cream Flavor | 120 | 1.50 | 50000 |
14 | 14 | Plantain | Africa | Green | Starch Rich | 300 | 0.70 | 600000 |
15 | 15 | Mysore_Banana | TamilNadu | Yellow | Helps Digestion | 95 | 0.60 | 250000 |
16 | 16 | Pisang Raja | Indonesia | Yellow | Vitamin C Source | 110 | 0.85 | 200000 |
17 | 17 | Praying_Hands | Thailand | Yellow | Symbolic Fruit | 200 | 1.00 | 180000 |
Step 2: Explore the Dataset with PROC PRINT
proc print data=Banana_Types noobs;
title "Different Types of Bananas - Raw Dataset";
run;
Output:
Different Types of Bananas - Raw Dataset |
Banana_ID | Variety | Origin | Color | Health_Benefit | Avg_Weight_grams | Price_Per_Kg_USD | Production_Tonnes_per_Year |
---|---|---|---|---|---|---|---|
1 | Cavendish | India | Yellow | Rich in Potassium | 120 | 0.45 | 900000 |
2 | Nendran | Kerala | Yellow | Aids Digestion | 150 | 0.60 | 500000 |
3 | Robusta | TamilNadu | Green | Energy Booster | 130 | 0.40 | 700000 |
4 | Rasthali | Karnataka | Yellow | Good for Skin | 100 | 0.70 | 300000 |
5 | Poovan | Andhra | White | Iron Rich | 90 | 0.35 | 200000 |
6 | Red_Banana | Maharashtra | Red | High Antioxidants | 160 | 1.20 | 150000 |
7 | Yelakki | Karnataka | Yellow | Kid-Friendly | 80 | 0.50 | 120000 |
8 | Monthan | TamilNadu | Green | Fiber Rich | 180 | 0.55 | 250000 |
9 | Karpooravalli | Kerala | Yellow | Soothes Ulcers | 140 | 0.65 | 300000 |
10 | Saba | Philippines | Green | Good for Heart | 200 | 0.80 | 800000 |
11 | Manzano | Ecuador | Yellow | Apple Taste | 100 | 0.95 | 100000 |
12 | Lady_Finger | Australia | Yellow | Low Calorie | 85 | 1.10 | 75000 |
13 | Blue_Java | Hawaii | Blue | Ice Cream Flavor | 120 | 1.50 | 50000 |
14 | Plantain | Africa | Green | Starch Rich | 300 | 0.70 | 600000 |
15 | Mysore_Banana | TamilNadu | Yellow | Helps Digestion | 95 | 0.60 | 250000 |
16 | Pisang Raja | Indonesia | Yellow | Vitamin C Source | 110 | 0.85 | 200000 |
17 | Praying_Hands | Thailand | Yellow | Symbolic Fruit | 200 | 1.00 | 180000 |
Step 3: Summary Statistics with PROC MEANS
proc means data=Banana_Types mean min max std;
var Avg_Weight_grams Price_Per_Kg_USD Production_Tonnes_per_Year;
title "Statistical Summary of Banana Metrics";
run;
Output:
Statistical Summary of Banana Metrics |
Variable | Mean | Minimum | Maximum | Std Dev | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
Step 4: Frequency Distribution with PROC FREQ
proc freq data=Banana_Types;
tables Color Origin;
title "Frequency Distribution of Banana Color and Origin";
run;
Output:
Frequency Distribution of Banana Color and Origin |
Color | Frequency | Percent | Cumulative Frequency |
Cumulative Percent |
---|---|---|---|---|
Blue | 1 | 5.88 | 1 | 5.88 |
Green | 4 | 23.53 | 5 | 29.41 |
Red | 1 | 5.88 | 6 | 35.29 |
White | 1 | 5.88 | 7 | 41.18 |
Yellow | 10 | 58.82 | 17 | 100.00 |
Origin | Frequency | Percent | Cumulative Frequency |
Cumulative Percent |
---|---|---|---|---|
Africa | 1 | 5.88 | 1 | 5.88 |
Andhra | 1 | 5.88 | 2 | 11.76 |
Australia | 1 | 5.88 | 3 | 17.65 |
Ecuador | 1 | 5.88 | 4 | 23.53 |
Hawaii | 1 | 5.88 | 5 | 29.41 |
India | 1 | 5.88 | 6 | 35.29 |
Indonesia | 1 | 5.88 | 7 | 41.18 |
Karnataka | 2 | 11.76 | 9 | 52.94 |
Kerala | 2 | 11.76 | 11 | 64.71 |
Maharashtra | 1 | 5.88 | 12 | 70.59 |
Philippines | 1 | 5.88 | 13 | 76.47 |
TamilNadu | 3 | 17.65 | 16 | 94.12 |
Thailand | 1 | 5.88 | 17 | 100.00 |
Step 5: Sorting Data with PROC SORT
proc sort data=Banana_Types out=Sorted_Bananas;
by descending Production_Tonnes_per_Year;
run;
proc print data=Sorted_Bananas;
title "Banana Types Sorted by Highest Production";
run;
Output:
Banana Types Sorted by Highest Production |
Obs | Banana_ID | Variety | Origin | Color | Health_Benefit | Avg_Weight_grams | Price_Per_Kg_USD | Production_Tonnes_per_Year |
---|---|---|---|---|---|---|---|---|
1 | 1 | Cavendish | India | Yellow | Rich in Potassium | 120 | 0.45 | 900000 |
2 | 10 | Saba | Philippines | Green | Good for Heart | 200 | 0.80 | 800000 |
3 | 3 | Robusta | TamilNadu | Green | Energy Booster | 130 | 0.40 | 700000 |
4 | 14 | Plantain | Africa | Green | Starch Rich | 300 | 0.70 | 600000 |
5 | 2 | Nendran | Kerala | Yellow | Aids Digestion | 150 | 0.60 | 500000 |
6 | 4 | Rasthali | Karnataka | Yellow | Good for Skin | 100 | 0.70 | 300000 |
7 | 9 | Karpooravalli | Kerala | Yellow | Soothes Ulcers | 140 | 0.65 | 300000 |
8 | 8 | Monthan | TamilNadu | Green | Fiber Rich | 180 | 0.55 | 250000 |
9 | 15 | Mysore_Banana | TamilNadu | Yellow | Helps Digestion | 95 | 0.60 | 250000 |
10 | 5 | Poovan | Andhra | White | Iron Rich | 90 | 0.35 | 200000 |
11 | 16 | Pisang Raja | Indonesia | Yellow | Vitamin C Source | 110 | 0.85 | 200000 |
12 | 17 | Praying_Hands | Thailand | Yellow | Symbolic Fruit | 200 | 1.00 | 180000 |
13 | 6 | Red_Banana | Maharashtra | Red | High Antioxidants | 160 | 1.20 | 150000 |
14 | 7 | Yelakki | Karnataka | Yellow | Kid-Friendly | 80 | 0.50 | 120000 |
15 | 11 | Manzano | Ecuador | Yellow | Apple Taste | 100 | 0.95 | 100000 |
16 | 12 | Lady_Finger | Australia | Yellow | Low Calorie | 85 | 1.10 | 75000 |
17 | 13 | Blue_Java | Hawaii | Blue | Ice Cream Flavor | 120 | 1.50 | 50000 |
Step 6: SQL Queries using PROC SQL
6.1: Select High Value Bananas
proc sql;
select Variety, Price_Per_Kg_USD
from Banana_Types
where Price_Per_Kg_USD > 1;
quit;
Output:
Variety | Price_Per_Kg_USD |
---|---|
Red_Banana | 1.2 |
Lady_Finger | 1.1 |
Blue_Java | 1.5 |
6.2: Group by Origin and Calculate Avg Production
proc sql;
select Origin, avg(Production_Tonnes_per_Year) as Avg_Production
from Banana_Types
group by Origin;
quit;
Output:
Origin | Avg_Production |
---|---|
Africa | 600000 |
Andhra | 200000 |
Australia | 75000 |
Ecuador | 100000 |
Hawaii | 50000 |
India | 900000 |
Indonesia | 200000 |
Karnataka | 210000 |
Kerala | 400000 |
Maharashtra | 150000 |
Philippines | 800000 |
TamilNadu | 400000 |
Thailand | 180000 |
6.3: Maximum Priced Banana
proc sql;
select Variety, Price_Per_Kg_USD
from Banana_Types
having Price_Per_Kg_USD = max(Price_Per_Kg_USD);
quit;
Output:
Variety | Price_Per_Kg_USD |
---|---|
Blue_Java | 1.5 |
Step 7: Use of PROC FORMAT
proc format;
value pricefmt
low -< 0.5 = 'Low'
0.5 -< 1 = 'Medium'
1 - high = 'High';
run;
data Banana_Types_Formatted;
set Banana_Types;
Price_Category = put(Price_Per_Kg_USD, pricefmt.);
run;
proc print;run;
Output:
Obs | Banana_ID | Variety | Origin | Color | Health_Benefit | Avg_Weight_grams | Price_Per_Kg_USD | Production_Tonnes_per_Year | Price_Category |
---|---|---|---|---|---|---|---|---|---|
1 | 1 | Cavendish | India | Yellow | Rich in Potassium | 120 | 0.45 | 900000 | Low |
2 | 2 | Nendran | Kerala | Yellow | Aids Digestion | 150 | 0.60 | 500000 | Medium |
3 | 3 | Robusta | TamilNadu | Green | Energy Booster | 130 | 0.40 | 700000 | Low |
4 | 4 | Rasthali | Karnataka | Yellow | Good for Skin | 100 | 0.70 | 300000 | Medium |
5 | 5 | Poovan | Andhra | White | Iron Rich | 90 | 0.35 | 200000 | Low |
6 | 6 | Red_Banana | Maharashtra | Red | High Antioxidants | 160 | 1.20 | 150000 | High |
7 | 7 | Yelakki | Karnataka | Yellow | Kid-Friendly | 80 | 0.50 | 120000 | Medium |
8 | 8 | Monthan | TamilNadu | Green | Fiber Rich | 180 | 0.55 | 250000 | Medium |
9 | 9 | Karpooravalli | Kerala | Yellow | Soothes Ulcers | 140 | 0.65 | 300000 | Medium |
10 | 10 | Saba | Philippines | Green | Good for Heart | 200 | 0.80 | 800000 | Medium |
11 | 11 | Manzano | Ecuador | Yellow | Apple Taste | 100 | 0.95 | 100000 | Medium |
12 | 12 | Lady_Finger | Australia | Yellow | Low Calorie | 85 | 1.10 | 75000 | High |
13 | 13 | Blue_Java | Hawaii | Blue | Ice Cream Flavor | 120 | 1.50 | 50000 | High |
14 | 14 | Plantain | Africa | Green | Starch Rich | 300 | 0.70 | 600000 | Medium |
15 | 15 | Mysore_Banana | TamilNadu | Yellow | Helps Digestion | 95 | 0.60 | 250000 | Medium |
16 | 16 | Pisang Raja | Indonesia | Yellow | Vitamin C Source | 110 | 0.85 | 200000 | Medium |
17 | 17 | Praying_Hands | Thailand | Yellow | Symbolic Fruit | 200 | 1.00 | 180000 | High |
proc freq data=Banana_Types_Formatted;
tables Price_Category;
title "Price Category Frequency";
run;
Output:
Price Category Frequency |
Price_Category | Frequency | Percent | Cumulative Frequency |
Cumulative Percent |
---|---|---|---|---|
High | 4 | 23.53 | 4 | 23.53 |
Low | 3 | 17.65 | 7 | 41.18 |
Medium | 10 | 58.82 | 17 | 100.00 |
Step 8: Create and Use a Macro
Define Macro to Filter Based on Origin
%macro filter_origin(region);
proc print data=Banana_Types;
where Origin="®ion";
title "Bananas Originating from ®ion";
run;
%mend;
%filter_origin(Kerala)
Output:
Bananas Originating from Kerala |
Obs | Banana_ID | Variety | Origin | Color | Health_Benefit | Avg_Weight_grams | Price_Per_Kg_USD | Production_Tonnes_per_Year |
---|---|---|---|---|---|---|---|---|
2 | 2 | Nendran | Kerala | Yellow | Aids Digestion | 150 | 0.60 | 500000 |
9 | 9 | Karpooravalli | Kerala | Yellow | Soothes Ulcers | 140 | 0.65 | 300000 |
%filter_origin(TamilNadu)
Output:
Bananas Originating from TamilNadu |
Obs | Banana_ID | Variety | Origin | Color | Health_Benefit | Avg_Weight_grams | Price_Per_Kg_USD | Production_Tonnes_per_Year |
---|---|---|---|---|---|---|---|---|
3 | 3 | Robusta | TamilNadu | Green | Energy Booster | 130 | 0.40 | 700000 |
8 | 8 | Monthan | TamilNadu | Green | Fiber Rich | 180 | 0.55 | 250000 |
15 | 15 | Mysore_Banana | TamilNadu | Yellow | Helps Digestion | 95 | 0.60 | 250000 |
Step 9: Macro to Calculate High Production Bananas
%macro high_production(min_production);
proc sql;
select Variety, Production_Tonnes_per_Year
from Banana_Types
where Production_Tonnes_per_Year > &min_production;
quit;
%mend;
%high_production(400000)
Output:
Variety | Production_Tonnes_per_Year |
---|---|
Cavendish | 900000 |
Nendran | 500000 |
Robusta | 700000 |
Saba | 800000 |
Plantain | 600000 |
Step 10: Create a New Derived Variable – Profit Estimation
data Banana_Types_Profit;
set Banana_Types;
Estimated_Profit_Million = (Price_Per_Kg_USD * Production_Tonnes_per_Year) / 1000000;
run;
proc print data=Banana_Types_Profit;
title "Estimated Profit in Million USD";
run;
Output:
Estimated Profit in Million USD |
Obs | Banana_ID | Variety | Origin | Color | Health_Benefit | Avg_Weight_grams | Price_Per_Kg_USD | Production_Tonnes_per_Year | Estimated_Profit_Million |
---|---|---|---|---|---|---|---|---|---|
1 | 1 | Cavendish | India | Yellow | Rich in Potassium | 120 | 0.45 | 900000 | 0.4050 |
2 | 2 | Nendran | Kerala | Yellow | Aids Digestion | 150 | 0.60 | 500000 | 0.3000 |
3 | 3 | Robusta | TamilNadu | Green | Energy Booster | 130 | 0.40 | 700000 | 0.2800 |
4 | 4 | Rasthali | Karnataka | Yellow | Good for Skin | 100 | 0.70 | 300000 | 0.2100 |
5 | 5 | Poovan | Andhra | White | Iron Rich | 90 | 0.35 | 200000 | 0.0700 |
6 | 6 | Red_Banana | Maharashtra | Red | High Antioxidants | 160 | 1.20 | 150000 | 0.1800 |
7 | 7 | Yelakki | Karnataka | Yellow | Kid-Friendly | 80 | 0.50 | 120000 | 0.0600 |
8 | 8 | Monthan | TamilNadu | Green | Fiber Rich | 180 | 0.55 | 250000 | 0.1375 |
9 | 9 | Karpooravalli | Kerala | Yellow | Soothes Ulcers | 140 | 0.65 | 300000 | 0.1950 |
10 | 10 | Saba | Philippines | Green | Good for Heart | 200 | 0.80 | 800000 | 0.6400 |
11 | 11 | Manzano | Ecuador | Yellow | Apple Taste | 100 | 0.95 | 100000 | 0.0950 |
12 | 12 | Lady_Finger | Australia | Yellow | Low Calorie | 85 | 1.10 | 75000 | 0.0825 |
13 | 13 | Blue_Java | Hawaii | Blue | Ice Cream Flavor | 120 | 1.50 | 50000 | 0.0750 |
14 | 14 | Plantain | Africa | Green | Starch Rich | 300 | 0.70 | 600000 | 0.4200 |
15 | 15 | Mysore_Banana | TamilNadu | Yellow | Helps Digestion | 95 | 0.60 | 250000 | 0.1500 |
16 | 16 | Pisang Raja | Indonesia | Yellow | Vitamin C Source | 110 | 0.85 | 200000 | 0.1700 |
17 | 17 | Praying_Hands | Thailand | Yellow | Symbolic Fruit | 200 | 1.00 | 180000 | 0.1800 |
Step 11: Data Cleaning – Remove Inconsistent Records
data Cleaned_Bananas;
set Banana_Types;
if Price_Per_Kg_USD > 0 and Avg_Weight_grams > 50 then output;
run;
proc print data=Cleaned_Bananas;
title "Cleaned Banana Dataset with Valid Prices and Weights";
run;
Output:
Cleaned Banana Dataset with Valid Prices and Weights |
Obs | Banana_ID | Variety | Origin | Color | Health_Benefit | Avg_Weight_grams | Price_Per_Kg_USD | Production_Tonnes_per_Year |
---|---|---|---|---|---|---|---|---|
1 | 1 | Cavendish | India | Yellow | Rich in Potassium | 120 | 0.45 | 900000 |
2 | 2 | Nendran | Kerala | Yellow | Aids Digestion | 150 | 0.60 | 500000 |
3 | 3 | Robusta | TamilNadu | Green | Energy Booster | 130 | 0.40 | 700000 |
4 | 4 | Rasthali | Karnataka | Yellow | Good for Skin | 100 | 0.70 | 300000 |
5 | 5 | Poovan | Andhra | White | Iron Rich | 90 | 0.35 | 200000 |
6 | 6 | Red_Banana | Maharashtra | Red | High Antioxidants | 160 | 1.20 | 150000 |
7 | 7 | Yelakki | Karnataka | Yellow | Kid-Friendly | 80 | 0.50 | 120000 |
8 | 8 | Monthan | TamilNadu | Green | Fiber Rich | 180 | 0.55 | 250000 |
9 | 9 | Karpooravalli | Kerala | Yellow | Soothes Ulcers | 140 | 0.65 | 300000 |
10 | 10 | Saba | Philippines | Green | Good for Heart | 200 | 0.80 | 800000 |
11 | 11 | Manzano | Ecuador | Yellow | Apple Taste | 100 | 0.95 | 100000 |
12 | 12 | Lady_Finger | Australia | Yellow | Low Calorie | 85 | 1.10 | 75000 |
13 | 13 | Blue_Java | Hawaii | Blue | Ice Cream Flavor | 120 | 1.50 | 50000 |
14 | 14 | Plantain | Africa | Green | Starch Rich | 300 | 0.70 | 600000 |
15 | 15 | Mysore_Banana | TamilNadu | Yellow | Helps Digestion | 95 | 0.60 | 250000 |
16 | 16 | Pisang Raja | Indonesia | Yellow | Vitamin C Source | 110 | 0.85 | 200000 |
17 | 17 | Praying_Hands | Thailand | Yellow | Symbolic Fruit | 200 | 1.00 | 180000 |
- Get link
- X
- Other Apps
Comments
Post a Comment