194.IN-DEPTH ANALYSIS AND VISUALIZATION OF INDIAN PALACES DATASET | USING PROC PRINT | PROC MEANS | PROC FREQ | PROC SORT | PROC SQL | MACROS FOR AUTOMATION | DATA CLEANING TECHNIQUES | STATISTICAL SUMMARY | ADVANCED REPORT GENERATION | INSIGHTS ON ARCHITECTURE AND TOURISM IMPACT
- Get link
- X
- Other Apps
IN-DEPTH ANALYSIS AND VISUALIZATION OF INDIAN PALACES DATASET | USING PROC PRINT | PROC MEANS | PROC FREQ | PROC SORT | PROC SQL | MACROS FOR AUTOMATION | DATA CLEANING TECHNIQUES | STATISTICAL SUMMARY | ADVANCED REPORT GENERATION | INSIGHTS ON ARCHITECTURE AND TOURISM IMPACT
/*Creating a unique dataset about different types of Indian palaces*/
Step 1: Create a Unique Dataset of Indian Palaces
data indian_palaces;
length Palace_ID $5 Palace_Name $20 Location $15 State $15 Architect $30 Style $20 Condition $10;
input Palace_ID :$5.
Palace_Name :$20.
Location :$15.
State :$15.
Architect :$30.
Style :$20.
Condition :$10.
Year_Built
Visitors_per_year
Ticket_Price
INR_Rs_in_Lakhs;
datalines;
P001 MysorePalace Mysore Karnataka HH_Mohan_Das Hindu Excellent 1912 2000000 300 500
P002 CityPalace Jaipur Rajasthan Maharaja_Sawai_Jai_Singh Rajput Good 1727 1500000 250 300
P003 UdaipurPalace Udaipur Rajasthan Maharana_Udai_Singh Rajput Excellent 1559 1000000 200 400
P004 HawaMahal Jaipur Rajasthan Lal_Chand_Ustad Rajput Good 1799 1200000 150 250
P005 AmberFort Jaipur Rajasthan Raja_Man_Singh Rajput Good 1592 1800000 200 350
P006 FalaknumaPalace Hyderabad Telangana Nawab_Vikar_ul_Mulk European Fair 1893 300000 1000 900
P007 ChowmahallaPalace Hyderabad Telangana Asaf_Jahi_Dynasty European Good 1750 400000 500 600
P008 CityPalace Bikaner Rajasthan Maharaja_Karan_Singh Rajput Fair 1594 500000 100 200
P009 UmaidBhawanPalace Jodhpur Rajasthan Henry_Lutyens Indo_Saracenic Excellent 1943 600000 600 700
P010 LaxmiVilasPalace Vadodara Gujarat Major_Charles_Mant Indo_Saracenic Fair 1890 250000 400 500
P011 JaiMahalPalace Jaipur Rajasthan Maharaja_Sawai_Man_Singh_II Rajput Good 1922 350000 300 400
P013 LalQila Delhi Delhi Shah_Jahan Mughal Excellent 1648 5000000 400 200
P014 RedFort Delhi Delhi Shah_Jahan Mughal Good 1639 4500000 350 180
P015 GolcondaFort Hyderabad Telangana Sultan_Quli_Qutub_Shah Fortification Fair 1518 700000 100 150
P016 JaisalmerFort Jaisalmer Rajasthan Rawal_Jaisal Rajput Good 1156 600000 150 100
;
run;
proc print;
run;
Output:
Obs | Palace_ID | Palace_Name | Location | State | Architect | Style | Condition | Year_Built | Visitors_per_year | Ticket_Price | INR_Rs_in_Lakhs |
---|---|---|---|---|---|---|---|---|---|---|---|
1 | P001 | MysorePalace | Mysore | Karnataka | HH_Mohan_Das | Hindu | Excellent | 1912 | 2000000 | 300 | 500 |
2 | P002 | CityPalace | Jaipur | Rajasthan | Maharaja_Sawai_Jai_Singh | Rajput | Good | 1727 | 1500000 | 250 | 300 |
3 | P003 | UdaipurPalace | Udaipur | Rajasthan | Maharana_Udai_Singh | Rajput | Excellent | 1559 | 1000000 | 200 | 400 |
4 | P004 | HawaMahal | Jaipur | Rajasthan | Lal_Chand_Ustad | Rajput | Good | 1799 | 1200000 | 150 | 250 |
5 | P005 | AmberFort | Jaipur | Rajasthan | Raja_Man_Singh | Rajput | Good | 1592 | 1800000 | 200 | 350 |
6 | P006 | FalaknumaPalace | Hyderabad | Telangana | Nawab_Vikar_ul_Mulk | European | Fair | 1893 | 300000 | 1000 | 900 |
7 | P007 | ChowmahallaPalace | Hyderabad | Telangana | Asaf_Jahi_Dynasty | European | Good | 1750 | 400000 | 500 | 600 |
8 | P008 | CityPalace | Bikaner | Rajasthan | Maharaja_Karan_Singh | Rajput | Fair | 1594 | 500000 | 100 | 200 |
9 | P009 | UmaidBhawanPalace | Jodhpur | Rajasthan | Henry_Lutyens | Indo_Saracenic | Excellent | 1943 | 600000 | 600 | 700 |
10 | P010 | LaxmiVilasPalace | Vadodara | Gujarat | Major_Charles_Mant | Indo_Saracenic | Fair | 1890 | 250000 | 400 | 500 |
11 | P011 | JaiMahalPalace | Jaipur | Rajasthan | Maharaja_Sawai_Man_Singh_II | Rajput | Good | 1922 | 350000 | 300 | 400 |
12 | P013 | LalQila | Delhi | Delhi | Shah_Jahan | Mughal | Excellent | 1648 | 5000000 | 400 | 200 |
13 | P014 | RedFort | Delhi | Delhi | Shah_Jahan | Mughal | Good | 1639 | 4500000 | 350 | 180 |
14 | P015 | GolcondaFort | Hyderabad | Telangana | Sultan_Quli_Qutub_Shah | Fortification | Fair | 1518 | 700000 | 100 | 150 |
15 | P016 | JaisalmerFort | Jaisalmer | Rajasthan | Rawal_Jaisal | Rajput | Good | 1156 | 600000 | 150 | 100 |
Step 2: PROC PRINT — View the Dataset
proc print data=indian_palaces label noobs;
title "List of Famous Indian Palaces with Attributes";
var Palace_ID Palace_Name Location State Year_Built Architect Style Visitors_per_year Ticket_Price INR_Rs_in_Lakhs Condition;
run;
Output:
List of Famous Indian Palaces with
Attributes |
Palace_ID | Palace_Name | Location | State | Year_Built | Architect | Style | Visitors_per_year | Ticket_Price | INR_Rs_in_Lakhs | Condition |
---|---|---|---|---|---|---|---|---|---|---|
P001 | MysorePalace | Mysore | Karnataka | 1912 | HH_Mohan_Das | Hindu | 2000000 | 300 | 500 | Excellent |
P002 | CityPalace | Jaipur | Rajasthan | 1727 | Maharaja_Sawai_Jai_Singh | Rajput | 1500000 | 250 | 300 | Good |
P003 | UdaipurPalace | Udaipur | Rajasthan | 1559 | Maharana_Udai_Singh | Rajput | 1000000 | 200 | 400 | Excellent |
P004 | HawaMahal | Jaipur | Rajasthan | 1799 | Lal_Chand_Ustad | Rajput | 1200000 | 150 | 250 | Good |
P005 | AmberFort | Jaipur | Rajasthan | 1592 | Raja_Man_Singh | Rajput | 1800000 | 200 | 350 | Good |
P006 | FalaknumaPalace | Hyderabad | Telangana | 1893 | Nawab_Vikar_ul_Mulk | European | 300000 | 1000 | 900 | Fair |
P007 | ChowmahallaPalace | Hyderabad | Telangana | 1750 | Asaf_Jahi_Dynasty | European | 400000 | 500 | 600 | Good |
P008 | CityPalace | Bikaner | Rajasthan | 1594 | Maharaja_Karan_Singh | Rajput | 500000 | 100 | 200 | Fair |
P009 | UmaidBhawanPalace | Jodhpur | Rajasthan | 1943 | Henry_Lutyens | Indo_Saracenic | 600000 | 600 | 700 | Excellent |
P010 | LaxmiVilasPalace | Vadodara | Gujarat | 1890 | Major_Charles_Mant | Indo_Saracenic | 250000 | 400 | 500 | Fair |
P011 | JaiMahalPalace | Jaipur | Rajasthan | 1922 | Maharaja_Sawai_Man_Singh_II | Rajput | 350000 | 300 | 400 | Good |
P013 | LalQila | Delhi | Delhi | 1648 | Shah_Jahan | Mughal | 5000000 | 400 | 200 | Excellent |
P014 | RedFort | Delhi | Delhi | 1639 | Shah_Jahan | Mughal | 4500000 | 350 | 180 | Good |
P015 | GolcondaFort | Hyderabad | Telangana | 1518 | Sultan_Quli_Qutub_Shah | Fortification | 700000 | 100 | 150 | Fair |
P016 | JaisalmerFort | Jaisalmer | Rajasthan | 1156 | Rawal_Jaisal | Rajput | 600000 | 150 | 100 | Good |
Step 3: PROC CONTENTS — Get Dataset Metadata
proc contents data=indian_palaces varnum;
title "Metadata for Indian Palaces Dataset";
run;
Output:
Metadata for Indian Palaces
Dataset |
Data Set Name | WORK.INDIAN_PALACES | Observations | 15 |
---|---|---|---|
Member Type | DATA | Variables | 11 |
Engine | V9 | Indexes | 0 |
Created | 14/09/2015 00:30:06 | Observation Length | 152 |
Last Modified | 14/09/2015 00:30:06 | Deleted Observations | 0 |
Protection | Compressed | NO | |
Data Set Type | Sorted | NO | |
Label | |||
Data Representation | WINDOWS_64 | ||
Encoding | wlatin1 Western (Windows) |
Engine/Host Dependent Information | |
---|---|
Data Set Page Size | 65536 |
Number of Data Set Pages | 1 |
First Data Page | 1 |
Max Obs per Page | 430 |
Obs in First Data Page | 15 |
Number of Data Set Repairs | 0 |
ExtendObsCounter | YES |
Filename | C:\Users\Lenovo\AppData\Local\Temp\SAS Temporary Files\_TD8864_DESKTOP-QFAA4KV_\indian_palaces.sas7bdat |
Release Created | 9.0401M2 |
Host Created | X64_8HOME |
Variables in Creation Order | |||
---|---|---|---|
# | Variable | Type | Len |
1 | Palace_ID | Char | 5 |
2 | Palace_Name | Char | 20 |
3 | Location | Char | 15 |
4 | State | Char | 15 |
5 | Architect | Char | 30 |
6 | Style | Char | 20 |
7 | Condition | Char | 10 |
8 | Year_Built | Num | 8 |
9 | Visitors_per_year | Num | 8 |
10 | Ticket_Price | Num | 8 |
11 | INR_Rs_in_Lakhs | Num | 8 |
Step 4: PROC FREQ — Frequency Distribution of Palace Conditions and Styles
proc freq data=indian_palaces order=freq;
tables Condition Style / nocum nopercent;
title "Frequency Distribution of Palace Condition and Architectural Style";
run;
Output:
Frequency Distribution of Palace Condition and Architectural Style |
Condition | Frequency |
---|---|
Good | 7 |
Excellent | 4 |
Fair | 4 |
Style | Frequency |
---|---|
Rajput | 7 |
European | 2 |
Indo_Saracenic | 2 |
Mughal | 2 |
Fortification | 1 |
Hindu | 1 |
Step 5: PROC MEANS — Statistical Summary of Numeric Variables
proc means data=indian_palaces mean median min max std n;
var Year_Built Visitors_per_year Ticket_Price INR_Rs_in_Lakhs;
title "Summary Statistics for Numeric Attributes of Indian Palaces";
run;
Output:
Summary Statistics for Numeric Attributes of Indian
Palaces |
Variable | Mean | Median | Minimum | Maximum | Std Dev | N | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
Step 6: PROC SORT — Sort Palaces by Visitors and Ticket Price
proc sort data=indian_palaces out=palaces_sorted;
by descending Visitors_per_year Ticket_Price;
run;
proc print data=palaces_sorted(obs=10) label noobs;
title "Top 10 Palaces by Visitors and Ticket Price";
var Palace_Name Visitors_per_year Ticket_Price Condition;
run;
Output:
Top 10 Palaces by Visitors and Ticket Price |
Palace_Name | Visitors_per_year | Ticket_Price | Condition |
---|---|---|---|
LalQila | 5000000 | 400 | Excellent |
RedFort | 4500000 | 350 | Good |
MysorePalace | 2000000 | 300 | Excellent |
AmberFort | 1800000 | 200 | Good |
CityPalace | 1500000 | 250 | Good |
HawaMahal | 1200000 | 150 | Good |
UdaipurPalace | 1000000 | 200 | Excellent |
GolcondaFort | 700000 | 100 | Fair |
JaisalmerFort | 600000 | 150 | Good |
UmaidBhawanPalace | 600000 | 600 | Excellent |
Step 7: PROC SQL — Advanced Queries
Query 1: Palaces with Visitors More Than 1 Million and Good or Excellent Condition
proc sql;
title "Palaces with >1 Million Visitors and Good/Excellent Condition";
select Palace_Name, Location, State, Visitors_per_year, Ticket_Price, Condition
from indian_palaces
where Visitors_per_year > 1000000 and Condition in ('Good', 'Excellent')
order by Visitors_per_year desc;
quit;
Output:
Palaces with >1 Million Visitors and Good/Excellent Condition |
Palace_Name | Location | State | Visitors_per_year | Ticket_Price | Condition |
---|---|---|---|---|---|
LalQila | Delhi | Delhi | 5000000 | 400 | Excellent |
RedFort | Delhi | Delhi | 4500000 | 350 | Good |
MysorePalace | Mysore | Karnataka | 2000000 | 300 | Excellent |
AmberFort | Jaipur | Rajasthan | 1800000 | 200 | Good |
CityPalace | Jaipur | Rajasthan | 1500000 | 250 | Good |
HawaMahal | Jaipur | Rajasthan | 1200000 | 150 | Good |
Query 2: Average Ticket Price by State
proc sql;
title "Average Ticket Price by State";
select State, round(mean(Ticket_Price), 1) as Avg_Ticket_Price format=8.2
from indian_palaces
group by State
order by Avg_Ticket_Price desc;
quit;
Output:
Average Ticket Price by State |
State | Avg_Ticket_Price |
---|---|
Telangana | 533.00 |
Gujarat | 400.00 |
Delhi | 375.00 |
Karnataka | 300.00 |
Rajasthan | 244.00 |
Query 3: Count of Palaces by Architectural Style
proc sql;
title "Number of Palaces by Architectural Style";
select Style, count(*) as Count
from indian_palaces
group by Style
order by Count desc;
quit;
Output:
Number of Palaces by Architectural Style |
Style | Count |
---|---|
Rajput | 7 |
Mughal | 2 |
European | 2 |
Indo_Saracenic | 2 |
Hindu | 1 |
Fortification | 1 |
Step 8: PROC FORMAT — Create User-defined Formats
proc format;
value $condfmt
'Excellent' = 'Top Condition'
'Good' = 'Well Maintained'
'Fair' = 'Needs Attention';
run;
Log:
NOTE: Format $CONDFMT has been output.
Step 9: Use PROC REPORT with Formats for a Summary Table
proc report data=indian_palaces nowd;
column State Style Palace_Name Visitors_per_year Ticket_Price Condition;
define State / group;
define Style / group;
define Palace_Name / display;
define Visitors_per_year / analysis sum format=comma12.;
define Ticket_Price / analysis mean format=dollar8.2;
define Condition / group format=$condfmt.;
title "Palace Summary Report by State and Style with Condition Formatting";
run;
Output:
Palace Summary Report by State and Style with Condition Formatting |
State | Style | Palace_Name | Visitors_per_year | Ticket_Price | Condition |
---|---|---|---|---|---|
Delhi | Mughal | LalQila | 5,000,000 | $400.00 | Top Condition |
RedFort | 4,500,000 | $350.00 | Well Maintained | ||
Gujarat | Indo_Saracenic | LaxmiVilasPalace | 250,000 | $400.00 | Needs Attention |
Karnataka | Hindu | MysorePalace | 2,000,000 | $300.00 | Top Condition |
Rajasthan | Indo_Saracenic | UmaidBhawanPalace | 600,000 | $600.00 | Top Condition |
Rajput | CityPalace | 500,000 | $100.00 | Needs Attention | |
UdaipurPalace | 1,000,000 | $200.00 | Top Condition | ||
CityPalace | 1,500,000 | $250.00 | Well Maintained | ||
HawaMahal | 1,200,000 | $150.00 | |||
AmberFort | 1,800,000 | $200.00 | |||
JaiMahalPalace | 350,000 | $300.00 | |||
JaisalmerFort | 600,000 | $150.00 | |||
Telangana | European | FalaknumaPalace | 300,000 | $1000.00 | Needs Attention |
ChowmahallaPalace | 400,000 | $500.00 | Well Maintained | ||
Fortification | GolcondaFort | 700,000 | $100.00 | Needs Attention |
Step 10: PROC TRANSPOSE — Reshape Data for Visitors and Ticket Price by Palace
proc transpose data=indian_palaces out=transposed_palaces(drop=_NAME_);
by Palace_ID Palace_Name;
var Visitors_per_year Ticket_Price;
run;
proc print data=transposed_palaces;
title "Transposed Visitors and Ticket Price by Palace";
run;
Output:
Transposed Visitors and Ticket Price by Palace |
Obs | Palace_ID | Palace_Name | COL1 |
---|---|---|---|
1 | P001 | MysorePalace | 2000000 |
2 | P001 | MysorePalace | 300 |
3 | P002 | CityPalace | 1500000 |
4 | P002 | CityPalace | 250 |
5 | P003 | UdaipurPalace | 1000000 |
6 | P003 | UdaipurPalace | 200 |
7 | P004 | HawaMahal | 1200000 |
8 | P004 | HawaMahal | 150 |
9 | P005 | AmberFort | 1800000 |
10 | P005 | AmberFort | 200 |
11 | P006 | FalaknumaPalace | 300000 |
12 | P006 | FalaknumaPalace | 1000 |
13 | P007 | ChowmahallaPalace | 400000 |
14 | P007 | ChowmahallaPalace | 500 |
15 | P008 | CityPalace | 500000 |
16 | P008 | CityPalace | 100 |
17 | P009 | UmaidBhawanPalace | 600000 |
18 | P009 | UmaidBhawanPalace | 600 |
19 | P010 | LaxmiVilasPalace | 250000 |
20 | P010 | LaxmiVilasPalace | 400 |
21 | P011 | JaiMahalPalace | 350000 |
22 | P011 | JaiMahalPalace | 300 |
23 | P013 | LalQila | 5000000 |
24 | P013 | LalQila | 400 |
25 | P014 | RedFort | 4500000 |
26 | P014 | RedFort | 350 |
27 | P015 | GolcondaFort | 700000 |
28 | P015 | GolcondaFort | 100 |
29 | P016 | JaisalmerFort | 600000 |
30 | P016 | JaisalmerFort | 150 |
Step 11: PROC UNIVARIATE — Distribution Analysis of Visitors and Ticket Price
proc univariate data=indian_palaces;
var Visitors_per_year Ticket_Price;
histogram / normal;
inset mean median std / position=ne;
title "Univariate Analysis of Visitors and Ticket Price";
run;
Log:
NOTE: PROCEDURE UNIVARIATE used (Total process time):
real time 4.89 seconds
cpu time 0.90 seconds
Step 12: PROC SGPLOT — Visualizing Ticket Price vs Visitors
proc sgplot data=indian_palaces;
scatter x=Visitors_per_year y=Ticket_Price / group=Condition markerattrs=(symbol=circlefilled size=10);
reg x=Visitors_per_year y=Ticket_Price / nomarkers;
xaxis label="Annual Visitors";
yaxis label="Ticket Price (INR)";
title "Scatter Plot of Ticket Price vs Annual Visitors by Palace Condition";
run;
Log:
NOTE: PROCEDURE SGPLOT used (Total process time):
real time 0.79 seconds
cpu time 0.06 seconds
NOTE: Listing image output written to SGPlot1.png.
NOTE: There were 15 observations read from the data set WORK.INDIAN_PALACES.
Step 13: Create a Macro to Filter Palaces Based on Minimum Visitors and Condition
%macro filter_palaces(min_visitors=, condition=);
proc sql;
title "Filtered Palaces with Visitors >= &min_visitors and Condition = &condition";
select Palace_ID, Palace_Name, Location, State, Visitors_per_year, Ticket_Price, Condition
from indian_palaces
where Visitors_per_year >= &min_visitors and Condition = "&condition"
order by Visitors_per_year desc;
quit;
%mend;
%filter_palaces(min_visitors=500000, condition=Good)
Output:
Filtered Palaces with Visitors >= 500000 and Condition = Good |
Palace_ID | Palace_Name | Location | State | Visitors_per_year | Ticket_Price | Condition |
---|---|---|---|---|---|---|
P014 | RedFort | Delhi | Delhi | 4500000 | 350 | Good |
P005 | AmberFort | Jaipur | Rajasthan | 1800000 | 200 | Good |
P002 | CityPalace | Jaipur | Rajasthan | 1500000 | 250 | Good |
P004 | HawaMahal | Jaipur | Rajasthan | 1200000 | 150 | Good |
P016 | JaisalmerFort | Jaisalmer | Rajasthan | 600000 | 150 | Good |
Step 14: PROC COMPARE — Compare Two Palace Datasets (Example: Original vs Modified)
data modified_palaces;
set indian_palaces;
if Palace_ID = "P002" then Ticket_Price = 300;
if Palace_ID = "P009" then Condition = "Good";
run;
proc compare base=indian_palaces compare=modified_palaces;
id Palace_ID;
var Ticket_Price Condition;
title "Comparison of Original vs Modified Palace Dataset";
run;
Output:
Step 15: PROC APPEND — Append a New Palace Record
data new_palace;
length Palace_ID $5 Palace_Name $20 Location $15 State $15 Architect $30 Style $20 Condition $10;
input Palace_ID :$5.
Palace_Name :$20.
Location :$15.
State :$15.
Architect :$30.
Style :$20.
Condition :$10.
Year_Built
Visitors_per_year
Ticket_Price
INR_Rs_in_Lakhs;
datalines;
P017 RajwadaPalace Indore MadhyaPradesh Malhar_Rao_Holkar Maratha Fair 1747 300000 150 120
;
run;
proc append base=indian_palaces data=new_palace force;
run;
proc print data=indian_palaces;
title "Indian Palaces Dataset After Adding a New Palace";
run;
Output:
Indian Palaces Dataset After Adding a New Palace |
Obs | Palace_ID | Palace_Name | Location | State | Architect | Style | Condition | Year_Built | Visitors_per_year | Ticket_Price | INR_Rs_in_Lakhs |
---|---|---|---|---|---|---|---|---|---|---|---|
1 | P001 | MysorePalace | Mysore | Karnataka | HH_Mohan_Das | Hindu | Excellent | 1912 | 2000000 | 300 | 500 |
2 | P002 | CityPalace | Jaipur | Rajasthan | Maharaja_Sawai_Jai_Singh | Rajput | Good | 1727 | 1500000 | 250 | 300 |
3 | P003 | UdaipurPalace | Udaipur | Rajasthan | Maharana_Udai_Singh | Rajput | Excellent | 1559 | 1000000 | 200 | 400 |
4 | P004 | HawaMahal | Jaipur | Rajasthan | Lal_Chand_Ustad | Rajput | Good | 1799 | 1200000 | 150 | 250 |
5 | P005 | AmberFort | Jaipur | Rajasthan | Raja_Man_Singh | Rajput | Good | 1592 | 1800000 | 200 | 350 |
6 | P006 | FalaknumaPalace | Hyderabad | Telangana | Nawab_Vikar_ul_Mulk | European | Fair | 1893 | 300000 | 1000 | 900 |
7 | P007 | ChowmahallaPalace | Hyderabad | Telangana | Asaf_Jahi_Dynasty | European | Good | 1750 | 400000 | 500 | 600 |
8 | P008 | CityPalace | Bikaner | Rajasthan | Maharaja_Karan_Singh | Rajput | Fair | 1594 | 500000 | 100 | 200 |
9 | P009 | UmaidBhawanPalace | Jodhpur | Rajasthan | Henry_Lutyens | Indo_Saracenic | Excellent | 1943 | 600000 | 600 | 700 |
10 | P010 | LaxmiVilasPalace | Vadodara | Gujarat | Major_Charles_Mant | Indo_Saracenic | Fair | 1890 | 250000 | 400 | 500 |
11 | P011 | JaiMahalPalace | Jaipur | Rajasthan | Maharaja_Sawai_Man_Singh_II | Rajput | Good | 1922 | 350000 | 300 | 400 |
12 | P013 | LalQila | Delhi | Delhi | Shah_Jahan | Mughal | Excellent | 1648 | 5000000 | 400 | 200 |
13 | P014 | RedFort | Delhi | Delhi | Shah_Jahan | Mughal | Good | 1639 | 4500000 | 350 | 180 |
14 | P015 | GolcondaFort | Hyderabad | Telangana | Sultan_Quli_Qutub_Shah | Fortification | Fair | 1518 | 700000 | 100 | 150 |
15 | P016 | JaisalmerFort | Jaisalmer | Rajasthan | Rawal_Jaisal | Rajput | Good | 1156 | 600000 | 150 | 100 |
16 | P017 | RajwadaPalace | Indore | MadhyaPradesh | Malhar_Rao_Holkar | Maratha | Fair | 1747 | 300000 | 150 | 120 |
Step 16: PROC SQL Macro — Summarize Visitors and Ticket Price by State and Condition
%macro palace_summary(state=, condition=);
proc sql;
title "Summary for &state Palaces with Condition &condition";
select count(*) as Num_Palaces,
sum(Visitors_per_year) as Total_Visitors format=comma12.,
mean(Ticket_Price) as Avg_Ticket_Price format=dollar8.2
from indian_palaces
where State = "&state" and Condition = "&condition";
quit;
%mend;
%palace_summary(state=Rajasthan, condition=Good)
Output:
Summary for Rajasthan Palaces with Condition Good |
Num_Palaces | Total_Visitors | Avg_Ticket_Price |
---|---|---|
5 | 5,450,000 | $210.00 |
Step 17: Final Dataset Summary — PROC SUMMARY
proc summary data=indian_palaces print;
class State Condition;
var Visitors_per_year Ticket_Price;
output out=summary_stats
mean= mean_Visitors mean_TicketPrice
sum= sum_Visitors sum_TicketPrice;
title "Summary Statistics by State and Condition";
run;
proc print data=summary_stats noobs;
title "Detailed Summary by State and Condition";
run;
Output:
Detailed Summary by State and Condition |
State | Condition | _TYPE_ | _FREQ_ | mean_Visitors | mean_TicketPrice | sum_Visitors | sum_TicketPrice |
---|---|---|---|---|---|---|---|
0 | 16 | 1312500.00 | 321.875 | 21000000 | 5150 | ||
Excellent | 1 | 4 | 2150000.00 | 375.000 | 8600000 | 1500 | |
Fair | 1 | 5 | 410000.00 | 350.000 | 2050000 | 1750 | |
Good | 1 | 7 | 1478571.43 | 271.429 | 10350000 | 1900 | |
Delhi | 2 | 2 | 4750000.00 | 375.000 | 9500000 | 750 | |
Gujarat | 2 | 1 | 250000.00 | 400.000 | 250000 | 400 | |
Karnataka | 2 | 1 | 2000000.00 | 300.000 | 2000000 | 300 | |
MadhyaPradesh | 2 | 1 | 300000.00 | 150.000 | 300000 | 150 | |
Rajasthan | 2 | 8 | 943750.00 | 243.750 | 7550000 | 1950 | |
Telangana | 2 | 3 | 466666.67 | 533.333 | 1400000 | 1600 | |
Delhi | Excellent | 3 | 1 | 5000000.00 | 400.000 | 5000000 | 400 |
Delhi | Good | 3 | 1 | 4500000.00 | 350.000 | 4500000 | 350 |
Gujarat | Fair | 3 | 1 | 250000.00 | 400.000 | 250000 | 400 |
Karnataka | Excellent | 3 | 1 | 2000000.00 | 300.000 | 2000000 | 300 |
MadhyaPradesh | Fair | 3 | 1 | 300000.00 | 150.000 | 300000 | 150 |
Rajasthan | Excellent | 3 | 2 | 800000.00 | 400.000 | 1600000 | 800 |
Rajasthan | Fair | 3 | 1 | 500000.00 | 100.000 | 500000 | 100 |
Rajasthan | Good | 3 | 5 | 1090000.00 | 210.000 | 5450000 | 1050 |
Telangana | Fair | 3 | 2 | 500000.00 | 550.000 | 1000000 | 1100 |
Telangana | Good | 3 | 1 | 400000.00 | 500.000 | 400000 | 500 |
Step 18: PROC EXPORT — Export Dataset to CSV for Reporting
proc export data=indian_palaces
outfile="/mnt/data/indian_palaces.csv"
dbms=csv
replace;
putnames=yes;
run;
Log:
NOTE: "/mnt/data/indian_palaces.csv" file was successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
real time 1.59 seconds
cpu time 0.12 seconds
- Get link
- X
- Other Apps
Comments
Post a Comment