205.ANALYZING ANCIENT ITEMS ARTIFACTS ACROSS CIVILIZATIONS USING PROC PRINT | PROC MEANS | PROC FREQ | PROC SORT | PROC SQL | PROC MACRO IN SAS TO EXPLORE HISTORY HERITAGE CULTURE AGE RARITY WEIGHT MATERIALS AND DISCOVERY LOCATIONS THROUGH ADVANCED DATA ANALYSIS
- Get link
- X
- Other Apps
ANALYZING ANCIENT ITEMS ARTIFACTS ACROSS CIVILIZATIONS USING PROC PRINT | PROC MEANS | PROC FREQ | PROC SORT | PROC SQL | PROC MACRO IN SAS TO EXPLORE HISTORY HERITAGE CULTURE AGE RARITY WEIGHT MATERIALS AND DISCOVERY LOCATIONS THROUGH ADVANCED DATA ANALYSIS
/*A custom dataset of Ancient Items*/
Step 1: Creating the Ancient Items Dataset
data Ancient_Items;
length Item_ID $15 Item_Name $20 Civilization $15 Category $15
Discovery_Location $15 Rarity_Level $15;
input Item_ID $ Item_Name $ Civilization $ Category $ Material $ Estimated_Age_Years
Weight_grams Discovery_Location $ Rarity_Level $;
datalines;
A001 Scroll_Edfu Egypt Scroll Papyrus 2200 150 Edfu Rare
A002 Harappa_Seal Indus Artifact Stone 4000 250 Harappa Unique
A003 Spartan_Sword Greece Weapon Iron 2500 300 Sparta Common
A004 Terracotta_Figure China Statue Clay 2300 500 Xian Rare
A005 Viking_Axe Scandinavia Weapon Iron 1200 850 Oslo Common
A006 Babylonian_Tablet Mesopotamia Tablet Clay 3500 400 Babylon Rare
A007 Roman_Coin Rome Currency Metal 1900 50 Rome Common
A008 Egyptian_Amulet Egypt Jewelry Gold 3000 80 Giza Rare
A009 Mayan_Calendar Mayan Tool Stone 1200 600 Yucatan Unique
A010 Samurai_Helmet Japan Armor Steel 900 1200 Kyoto Rare
A011 Persian_Cup Persia Vessel Bronze 2700 450 Persepolis Rare
A012 Celtic_Shield Europe Armor Iron 1800 2000 Dublin Common
A013 Aztec_Knife Aztec Weapon Obsidian 1000 350 Tenochtitlan Unique
A014 Greek_Vase Greece Vessel Ceramic 2600 550 Athens Rare
A015 Stone_Hammer Prehistoric Tool Stone 5000 800 Altamira Common
A016 Oracle_Bone China Divination Bone 3200 300 Anyang Rare
A017 Incan_Necklace Inca Jewelry Silver 1400 60 Cusco Rare
;
run;
proc print;run;
Output:
Obs | Item_ID | Item_Name | Civilization | Category | Discovery_Location | Rarity_Level | Material | Estimated_Age_Years | Weight_grams |
---|---|---|---|---|---|---|---|---|---|
1 | A001 | Scroll_Edfu | Egypt | Scroll | Edfu | Rare | Papyrus | 2200 | 150 |
2 | A002 | Harappa_Seal | Indus | Artifact | Harappa | Unique | Stone | 4000 | 250 |
3 | A003 | Spartan_Sword | Greece | Weapon | Sparta | Common | Iron | 2500 | 300 |
4 | A004 | Terracotta_Figure | China | Statue | Xian | Rare | Clay | 2300 | 500 |
5 | A005 | Viking_Axe | Scandinavia | Weapon | Oslo | Common | Iron | 1200 | 850 |
6 | A006 | Babylonian_Tablet | Mesopotamia | Tablet | Babylon | Rare | Clay | 3500 | 400 |
7 | A007 | Roman_Coin | Rome | Currency | Rome | Common | Metal | 1900 | 50 |
8 | A008 | Egyptian_Amulet | Egypt | Jewelry | Giza | Rare | Gold | 3000 | 80 |
9 | A009 | Mayan_Calendar | Mayan | Tool | Yucatan | Unique | Stone | 1200 | 600 |
10 | A010 | Samurai_Helmet | Japan | Armor | Kyoto | Rare | Steel | 900 | 1200 |
11 | A011 | Persian_Cup | Persia | Vessel | Persepolis | Rare | Bronze | 2700 | 450 |
12 | A012 | Celtic_Shield | Europe | Armor | Dublin | Common | Iron | 1800 | 2000 |
13 | A013 | Aztec_Knife | Aztec | Weapon | Tenochtitlan | Unique | Obsidian | 1000 | 350 |
14 | A014 | Greek_Vase | Greece | Vessel | Athens | Rare | Ceramic | 2600 | 550 |
15 | A015 | Stone_Hammer | Prehistoric | Tool | Altamira | Common | Stone | 5000 | 800 |
16 | A016 | Oracle_Bone | China | Divination | Anyang | Rare | Bone | 3200 | 300 |
17 | A017 | Incan_Necklace | Inca | Jewelry | Cusco | Rare | Silver | 1400 | 60 |
Step 2: PROC PRINT – Display the Entire Dataset
title "Display of Ancient Items Dataset";
proc print data=Ancient_Items noobs;
run;
Output:
Display of Ancient Items Dataset |
Item_ID | Item_Name | Civilization | Category | Discovery_Location | Rarity_Level | Material | Estimated_Age_Years | Weight_grams |
---|---|---|---|---|---|---|---|---|
A001 | Scroll_Edfu | Egypt | Scroll | Edfu | Rare | Papyrus | 2200 | 150 |
A002 | Harappa_Seal | Indus | Artifact | Harappa | Unique | Stone | 4000 | 250 |
A003 | Spartan_Sword | Greece | Weapon | Sparta | Common | Iron | 2500 | 300 |
A004 | Terracotta_Figure | China | Statue | Xian | Rare | Clay | 2300 | 500 |
A005 | Viking_Axe | Scandinavia | Weapon | Oslo | Common | Iron | 1200 | 850 |
A006 | Babylonian_Tablet | Mesopotamia | Tablet | Babylon | Rare | Clay | 3500 | 400 |
A007 | Roman_Coin | Rome | Currency | Rome | Common | Metal | 1900 | 50 |
A008 | Egyptian_Amulet | Egypt | Jewelry | Giza | Rare | Gold | 3000 | 80 |
A009 | Mayan_Calendar | Mayan | Tool | Yucatan | Unique | Stone | 1200 | 600 |
A010 | Samurai_Helmet | Japan | Armor | Kyoto | Rare | Steel | 900 | 1200 |
A011 | Persian_Cup | Persia | Vessel | Persepolis | Rare | Bronze | 2700 | 450 |
A012 | Celtic_Shield | Europe | Armor | Dublin | Common | Iron | 1800 | 2000 |
A013 | Aztec_Knife | Aztec | Weapon | Tenochtitlan | Unique | Obsidian | 1000 | 350 |
A014 | Greek_Vase | Greece | Vessel | Athens | Rare | Ceramic | 2600 | 550 |
A015 | Stone_Hammer | Prehistoric | Tool | Altamira | Common | Stone | 5000 | 800 |
A016 | Oracle_Bone | China | Divination | Anyang | Rare | Bone | 3200 | 300 |
A017 | Incan_Necklace | Inca | Jewelry | Cusco | Rare | Silver | 1400 | 60 |
Step 3: PROC SORT – Sort by Civilization and Age
title "Sorted Ancient Items by Civilization and Age";
proc sort data=Ancient_Items out=Sorted_Items;
by Civilization descending Estimated_Age_Years;
run;
proc print data=Sorted_Items;
run;
Output:
Sorted Ancient Items by Civilization and Age |
Obs | Item_ID | Item_Name | Civilization | Category | Discovery_Location | Rarity_Level | Material | Estimated_Age_Years | Weight_grams |
---|---|---|---|---|---|---|---|---|---|
1 | A013 | Aztec_Knife | Aztec | Weapon | Tenochtitlan | Unique | Obsidian | 1000 | 350 |
2 | A016 | Oracle_Bone | China | Divination | Anyang | Rare | Bone | 3200 | 300 |
3 | A004 | Terracotta_Figure | China | Statue | Xian | Rare | Clay | 2300 | 500 |
4 | A008 | Egyptian_Amulet | Egypt | Jewelry | Giza | Rare | Gold | 3000 | 80 |
5 | A001 | Scroll_Edfu | Egypt | Scroll | Edfu | Rare | Papyrus | 2200 | 150 |
6 | A012 | Celtic_Shield | Europe | Armor | Dublin | Common | Iron | 1800 | 2000 |
7 | A014 | Greek_Vase | Greece | Vessel | Athens | Rare | Ceramic | 2600 | 550 |
8 | A003 | Spartan_Sword | Greece | Weapon | Sparta | Common | Iron | 2500 | 300 |
9 | A017 | Incan_Necklace | Inca | Jewelry | Cusco | Rare | Silver | 1400 | 60 |
10 | A002 | Harappa_Seal | Indus | Artifact | Harappa | Unique | Stone | 4000 | 250 |
11 | A010 | Samurai_Helmet | Japan | Armor | Kyoto | Rare | Steel | 900 | 1200 |
12 | A009 | Mayan_Calendar | Mayan | Tool | Yucatan | Unique | Stone | 1200 | 600 |
13 | A006 | Babylonian_Tablet | Mesopotamia | Tablet | Babylon | Rare | Clay | 3500 | 400 |
14 | A011 | Persian_Cup | Persia | Vessel | Persepolis | Rare | Bronze | 2700 | 450 |
15 | A015 | Stone_Hammer | Prehistoric | Tool | Altamira | Common | Stone | 5000 | 800 |
16 | A007 | Roman_Coin | Rome | Currency | Rome | Common | Metal | 1900 | 50 |
17 | A005 | Viking_Axe | Scandinavia | Weapon | Oslo | Common | Iron | 1200 | 850 |
Step 4: PROC MEANS – Analyze Numeric Variables
title "Statistical Summary of Age and Weight of Ancient Items";
proc means data=Ancient_Items min max mean median std;
var Estimated_Age_Years Weight_grams;
run;
Output:
Statistical Summary of Age and Weight of Ancient Items |
Variable | Minimum | Maximum | Mean | Median | Std Dev | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
Step 5: PROC FREQ – Frequency of Categories and Materials
title "Frequency of Ancient Item Categories";
proc freq data=Ancient_Items;
tables Category Material Rarity_Level / nocum nopercent;
run;
Output:
Frequency of Ancient Item Categories |
Category | Frequency |
---|---|
Armor | 2 |
Artifact | 1 |
Currency | 1 |
Divination | 1 |
Jewelry | 2 |
Scroll | 1 |
Statue | 1 |
Tablet | 1 |
Tool | 2 |
Vessel | 2 |
Weapon | 3 |
Material | Frequency |
---|---|
Bone | 1 |
Bronze | 1 |
Ceramic | 1 |
Clay | 2 |
Gold | 1 |
Iron | 3 |
Metal | 1 |
Obsidian | 1 |
Papyrus | 1 |
Silver | 1 |
Steel | 1 |
Stone | 3 |
Rarity_Level | Frequency |
---|---|
Common | 5 |
Rare | 9 |
Unique | 3 |
Step 6: PROC SQL – Use SQL for Data Filtering and Aggregation
A. List all Unique Civilizations
proc sql;
title "List of Civilizations in Dataset";
select distinct Civilization from Ancient_Items;
quit;
Output:
List of Civilizations in Dataset |
Civilization |
---|
Aztec |
China |
Egypt |
Europe |
Greece |
Inca |
Indus |
Japan |
Mayan |
Mesopotamia |
Persia |
Prehistoric |
Rome |
Scandinavia |
B. Average Age per Category
proc sql;
title "Average Estimated Age by Item Category";
select Category, avg(Estimated_Age_Years) as Avg_Age
from Ancient_Items
group by Category;
quit;
Output:
Average Estimated Age by Item Category |
Category | Avg_Age |
---|---|
Armor | 1350 |
Artifact | 4000 |
Currency | 1900 |
Divination | 3200 |
Jewelry | 2200 |
Scroll | 2200 |
Statue | 2300 |
Tablet | 3500 |
Tool | 3100 |
Vessel | 2650 |
Weapon | 1566.667 |
C. Heaviest Item from Each Civilization
proc sql;
title "Heaviest Item from Each Civilization";
select a.Civilization, a.Item_Name, a.Weight_grams
from Ancient_Items as a
inner join (
select Civilization, max(Weight_grams) as Max_Weight
from Ancient_Items
group by Civilization
) as b
on a.Civilization = b.Civilization and a.Weight_grams = b.Max_Weight;
quit;
Output:
Heaviest Item from Each Civilization |
Civilization | Item_Name | Weight_grams |
---|---|---|
Egypt | Scroll_Edfu | 150 |
Indus | Harappa_Seal | 250 |
China | Terracotta_Figure | 500 |
Scandinavia | Viking_Axe | 850 |
Mesopotamia | Babylonian_Tablet | 400 |
Rome | Roman_Coin | 50 |
Mayan | Mayan_Calendar | 600 |
Japan | Samurai_Helmet | 1200 |
Persia | Persian_Cup | 450 |
Europe | Celtic_Shield | 2000 |
Aztec | Aztec_Knife | 350 |
Greece | Greek_Vase | 550 |
Prehistoric | Stone_Hammer | 800 |
Inca | Incan_Necklace | 60 |
Step 7: PROC MACRO – Automate Filtering by Civilization
Define a Macro to Filter Items by Civilization:
%macro FilterByCivilization(civ);
title "Items from &civ Civilization";
proc print data=Ancient_Items;
where Civilization = "&civ";
run;
%mend;
%FilterByCivilization(Egypt);
Output:
Items from Egypt Civilization |
Obs | Item_ID | Item_Name | Civilization | Category | Discovery_Location | Rarity_Level | Material | Estimated_Age_Years | Weight_grams |
---|---|---|---|---|---|---|---|---|---|
1 | A001 | Scroll_Edfu | Egypt | Scroll | Edfu | Rare | Papyrus | 2200 | 150 |
8 | A008 | Egyptian_Amulet | Egypt | Jewelry | Giza | Rare | Gold | 3000 | 80 |
%FilterByCivilization(Greece);
Output:
Items from Greece Civilization |
Obs | Item_ID | Item_Name | Civilization | Category | Discovery_Location | Rarity_Level | Material | Estimated_Age_Years | Weight_grams |
---|---|---|---|---|---|---|---|---|---|
3 | A003 | Spartan_Sword | Greece | Weapon | Sparta | Common | Iron | 2500 | 300 |
14 | A014 | Greek_Vase | Greece | Vessel | Athens | Rare | Ceramic | 2600 | 550 |
%FilterByCivilization(China);
Output:
Items from China Civilization |
Obs | Item_ID | Item_Name | Civilization | Category | Discovery_Location | Rarity_Level | Material | Estimated_Age_Years | Weight_grams |
---|---|---|---|---|---|---|---|---|---|
4 | A004 | Terracotta_Figure | China | Statue | Xian | Rare | Clay | 2300 | 500 |
16 | A016 | Oracle_Bone | China | Divination | Anyang | Rare | Bone | 3200 | 300 |
Step 8: Advanced Macro to Compute Stats for Specific Material
%macro MaterialStats(material);
title "Analysis of Items Made from &material";
proc sql;
select count(*) as Count, avg(Estimated_Age_Years) as Avg_Age,
min(Weight_grams) as Min_Weight, max(Weight_grams) as Max_Weight
from Ancient_Items
where Material = "&material";
quit;
%mend;
%MaterialStats(Stone);
Output:
Analysis of Items Made from Stone |
Count | Avg_Age | Min_Weight | Max_Weight |
---|---|---|---|
3 | 3400 | 250 | 800 |
%MaterialStats(Iron);
Output:
Analysis of Items Made from Iron |
Count | Avg_Age | Min_Weight | Max_Weight |
---|---|---|---|
3 | 1833.333 | 300 | 2000 |
Step 9: Custom Insight Examples
Oldest Items Above 3000 Years:
proc sql;
title "Items Older than 3000 Years";
select Item_Name, Civilization, Estimated_Age_Years
from Ancient_Items
where Estimated_Age_Years > 3000
order by Estimated_Age_Years desc;
quit;
Output:
Items Older than 3000 Years |
Item_Name | Civilization | Estimated_Age_Years |
---|---|---|
Stone_Hammer | Prehistoric | 5000 |
Harappa_Seal | Indus | 4000 |
Babylonian_Tablet | Mesopotamia | 3500 |
Oracle_Bone | China | 3200 |
Unique Items List:
proc sql;
title "List of Unique Ancient Items";
select Item_Name, Civilization, Category
from Ancient_Items
where Rarity_Level = "Unique";
quit;
Output:
List of Unique Ancient Items |
Item_Name | Civilization | Category |
---|---|---|
Harappa_Seal | Indus | Artifact |
Mayan_Calendar | Mayan | Tool |
Aztec_Knife | Aztec | Weapon |
Step 10:Exporting Final Dataset
proc export data=Ancient_Items
outfile="AncientItems.csv"
dbms=csv
replace;
run;
Log:
- Get link
- X
- Other Apps
Comments
Post a Comment