254.EXPLORATORY ANALYSIS OF DIFFERENT TYPES OF VACATION PLACES IN INDIA USING PROC PRINT | PROC SORT | PROC MEANS | PROC FREQ | PROC UNIVARIATE | PROC TRANSPOSE | PROC SGPLOT | PROC SQL | MACROS IN SAS
- Get link
- X
- Other Apps
EXPLORATORY ANALYSIS OF DIFFERENT TYPES OF VACATION PLACES IN INDIA USING PROC PRINT | PROC SORT | PROC MEANS | PROC FREQ | PROC UNIVARIATE | PROC TRANSPOSE | PROC SGPLOT | PROC SQL | MACROS IN SAS
/*A real-world dataset of different types of vacation places across India*/
1. DATASET CREATION – VACATION_PLACES_INDIA
options nocenter;
data vacation_places_india;
length Place_ID 8 Name $30 State $20 Region $15
Type $20 Ideal_Season $15 Popular_Activity $30
Avg_Cost_Per_Person 8 Rating 8;
input Place_ID Name $ State $ Region $ Type $
Ideal_Season $ Popular_Activity $ Avg_Cost_Per_Person Rating;
datalines;
1 Manali Himachal_Pradesh North HillStation Summer Skiing 15000 4.7
2 Goa Goa West Beach Winter Party 18000 4.8
3 Jaipur Rajasthan West Heritage Winter Fort_Visit 14000 4.5
4 Darjeeling West_Bengal East HillStation Summer Toy_Train 12000 4.4
5 Ooty Tamil_Nadu South HillStation Summer Botanical_Garden 13000 4.6
6 Munnar Kerala South HillStation Monsoon Tea_Estate_Tour 14000 4.5
7 Udaipur Rajasthan West Heritage Winter Lake_Tour 16000 4.3
8 Rishikesh Uttarakhand North Spiritual Winter River_Rafting 9000 4.6
9 Andaman Islands UT Beach Winter Snorkeling 25000 4.8
10 Varanasi Uttar_Pradesh North Spiritual Winter Ganga_Aarti 11000 4.5
11 Leh Ladakh North Adventure Summer Biking 20000 4.9
12 Mysore Karnataka South Heritage Winter Palace_Visit 10000 4.2
13 Kochi Kerala South Backwater Monsoon Houseboat 17000 4.4
14 Shillong Meghalaya East HillStation Summer Waterfalls 15000 4.3
15 Hampi Karnataka South Heritage Winter Ruins_Tour 14000 4.1
16 Agra Uttar_Pradesh North Heritage Winter Taj_Mahal 12000 4.7
17 Kanyakumari Tamil_Nadu South Coastal Winter Sunrise_View 13000 4.2
18 Gulmarg Jammu_and_Kashmir North HillStation Winter Skiing 18000 4.8
19 Puri Odisha East Beach Winter Temple_Visit 10000 4.3
20 Mahabalipuram Tamil_Nadu South Heritage Winter Temple_Sculptures 11000 4.1
21 Auli Uttarakhand North Adventure Winter Skiing 16000 4.6
22 Rameswaram Tamil_Nadu South Spiritual Winter Temple_Tour 10000 4.4
23 Khajuraho Madhya_Pradesh Central Heritage Winter Erotic_Sculptures 14000 4.0
24 Sikkim Sikkim East HillStation Summer Trekking 17000 4.5
25 Mount_Abu Rajasthan West HillStation Summer Lake_Boating 12000 4.2
26 Lonavala Maharashtra West HillStation Monsoon Nature_Walk 9000 4.1
27 Coorg Karnataka South HillStation Monsoon Coffee_Plantation 13000 4.3
;
run;
proc print;run;
Output:
Obs | Place_ID | Name | State | Region | Type | Ideal_Season | Popular_Activity | Avg_Cost_Per_Person | Rating |
---|---|---|---|---|---|---|---|---|---|
1 | 1 | Manali | Himachal_Pradesh | North | HillStation | Summer | Skiing | 15000 | 4.7 |
2 | 2 | Goa | Goa | West | Beach | Winter | Party | 18000 | 4.8 |
3 | 3 | Jaipur | Rajasthan | West | Heritage | Winter | Fort_Visit | 14000 | 4.5 |
4 | 4 | Darjeeling | West_Bengal | East | HillStation | Summer | Toy_Train | 12000 | 4.4 |
5 | 5 | Ooty | Tamil_Nadu | South | HillStation | Summer | Botanical_Garden | 13000 | 4.6 |
6 | 6 | Munnar | Kerala | South | HillStation | Monsoon | Tea_Estate_Tour | 14000 | 4.5 |
7 | 7 | Udaipur | Rajasthan | West | Heritage | Winter | Lake_Tour | 16000 | 4.3 |
8 | 8 | Rishikesh | Uttarakhand | North | Spiritual | Winter | River_Rafting | 9000 | 4.6 |
9 | 9 | Andaman | Islands | UT | Beach | Winter | Snorkeling | 25000 | 4.8 |
10 | 10 | Varanasi | Uttar_Pradesh | North | Spiritual | Winter | Ganga_Aarti | 11000 | 4.5 |
11 | 11 | Leh | Ladakh | North | Adventure | Summer | Biking | 20000 | 4.9 |
12 | 12 | Mysore | Karnataka | South | Heritage | Winter | Palace_Visit | 10000 | 4.2 |
13 | 13 | Kochi | Kerala | South | Backwater | Monsoon | Houseboat | 17000 | 4.4 |
14 | 14 | Shillong | Meghalaya | East | HillStation | Summer | Waterfalls | 15000 | 4.3 |
15 | 15 | Hampi | Karnataka | South | Heritage | Winter | Ruins_Tour | 14000 | 4.1 |
16 | 16 | Agra | Uttar_Pradesh | North | Heritage | Winter | Taj_Mahal | 12000 | 4.7 |
17 | 17 | Kanyakumari | Tamil_Nadu | South | Coastal | Winter | Sunrise_View | 13000 | 4.2 |
18 | 18 | Gulmarg | Jammu_and_Kashmir | North | HillStation | Winter | Skiing | 18000 | 4.8 |
19 | 19 | Puri | Odisha | East | Beach | Winter | Temple_Visit | 10000 | 4.3 |
20 | 20 | Mahabalipuram | Tamil_Nadu | South | Heritage | Winter | Temple_Sculptures | 11000 | 4.1 |
21 | 21 | Auli | Uttarakhand | North | Adventure | Winter | Skiing | 16000 | 4.6 |
22 | 22 | Rameswaram | Tamil_Nadu | South | Spiritual | Winter | Temple_Tour | 10000 | 4.4 |
23 | 23 | Khajuraho | Madhya_Pradesh | Central | Heritage | Winter | Erotic_Sculptures | 14000 | 4.0 |
24 | 24 | Sikkim | Sikkim | East | HillStation | Summer | Trekking | 17000 | 4.5 |
25 | 25 | Mount_Abu | Rajasthan | West | HillStation | Summer | Lake_Boating | 12000 | 4.2 |
26 | 26 | Lonavala | Maharashtra | West | HillStation | Monsoon | Nature_Walk | 9000 | 4.1 |
27 | 27 | Coorg | Karnataka | South | HillStation | Monsoon | Coffee_Plantation | 13000 | 4.3 |
2. PROC PRINT – To display the entire dataset
Purpose: To print and display all vacation place records
proc print data=vacation_places_india;
title "All Vacation Places in India";
run;
Output:
All Vacation Places in India
Obs | Place_ID | Name | State | Region | Type | Ideal_Season | Popular_Activity | Avg_Cost_Per_Person | Rating |
---|---|---|---|---|---|---|---|---|---|
1 | 1 | Manali | Himachal_Pradesh | North | HillStation | Summer | Skiing | 15000 | 4.7 |
2 | 2 | Goa | Goa | West | Beach | Winter | Party | 18000 | 4.8 |
3 | 3 | Jaipur | Rajasthan | West | Heritage | Winter | Fort_Visit | 14000 | 4.5 |
4 | 4 | Darjeeling | West_Bengal | East | HillStation | Summer | Toy_Train | 12000 | 4.4 |
5 | 5 | Ooty | Tamil_Nadu | South | HillStation | Summer | Botanical_Garden | 13000 | 4.6 |
6 | 6 | Munnar | Kerala | South | HillStation | Monsoon | Tea_Estate_Tour | 14000 | 4.5 |
7 | 7 | Udaipur | Rajasthan | West | Heritage | Winter | Lake_Tour | 16000 | 4.3 |
8 | 8 | Rishikesh | Uttarakhand | North | Spiritual | Winter | River_Rafting | 9000 | 4.6 |
9 | 9 | Andaman | Islands | UT | Beach | Winter | Snorkeling | 25000 | 4.8 |
10 | 10 | Varanasi | Uttar_Pradesh | North | Spiritual | Winter | Ganga_Aarti | 11000 | 4.5 |
11 | 11 | Leh | Ladakh | North | Adventure | Summer | Biking | 20000 | 4.9 |
12 | 12 | Mysore | Karnataka | South | Heritage | Winter | Palace_Visit | 10000 | 4.2 |
13 | 13 | Kochi | Kerala | South | Backwater | Monsoon | Houseboat | 17000 | 4.4 |
14 | 14 | Shillong | Meghalaya | East | HillStation | Summer | Waterfalls | 15000 | 4.3 |
15 | 15 | Hampi | Karnataka | South | Heritage | Winter | Ruins_Tour | 14000 | 4.1 |
16 | 16 | Agra | Uttar_Pradesh | North | Heritage | Winter | Taj_Mahal | 12000 | 4.7 |
17 | 17 | Kanyakumari | Tamil_Nadu | South | Coastal | Winter | Sunrise_View | 13000 | 4.2 |
18 | 18 | Gulmarg | Jammu_and_Kashmir | North | HillStation | Winter | Skiing | 18000 | 4.8 |
19 | 19 | Puri | Odisha | East | Beach | Winter | Temple_Visit | 10000 | 4.3 |
20 | 20 | Mahabalipuram | Tamil_Nadu | South | Heritage | Winter | Temple_Sculptures | 11000 | 4.1 |
21 | 21 | Auli | Uttarakhand | North | Adventure | Winter | Skiing | 16000 | 4.6 |
22 | 22 | Rameswaram | Tamil_Nadu | South | Spiritual | Winter | Temple_Tour | 10000 | 4.4 |
23 | 23 | Khajuraho | Madhya_Pradesh | Central | Heritage | Winter | Erotic_Sculptures | 14000 | 4.0 |
24 | 24 | Sikkim | Sikkim | East | HillStation | Summer | Trekking | 17000 | 4.5 |
25 | 25 | Mount_Abu | Rajasthan | West | HillStation | Summer | Lake_Boating | 12000 | 4.2 |
26 | 26 | Lonavala | Maharashtra | West | HillStation | Monsoon | Nature_Walk | 9000 | 4.1 |
27 | 27 | Coorg | Karnataka | South | HillStation | Monsoon | Coffee_Plantation | 13000 | 4.3 |
3. PROC SORT – Sort places by cost
Purpose: To sort vacation places by highest to lowest average cost
proc sort data=vacation_places_india out=sorted_by_cost;
by descending Avg_Cost_Per_Person;
run;
proc print data = sorted_by_cost(obs=10);
run;
Output:
Obs | Place_ID | Name | State | Region | Type | Ideal_Season | Popular_Activity | Avg_Cost_Per_Person | Rating |
---|---|---|---|---|---|---|---|---|---|
1 | 9 | Andaman | Islands | UT | Beach | Winter | Snorkeling | 25000 | 4.8 |
2 | 11 | Leh | Ladakh | North | Adventure | Summer | Biking | 20000 | 4.9 |
3 | 2 | Goa | Goa | West | Beach | Winter | Party | 18000 | 4.8 |
4 | 18 | Gulmarg | Jammu_and_Kashmir | North | HillStation | Winter | Skiing | 18000 | 4.8 |
5 | 13 | Kochi | Kerala | South | Backwater | Monsoon | Houseboat | 17000 | 4.4 |
6 | 24 | Sikkim | Sikkim | East | HillStation | Summer | Trekking | 17000 | 4.5 |
7 | 7 | Udaipur | Rajasthan | West | Heritage | Winter | Lake_Tour | 16000 | 4.3 |
8 | 21 | Auli | Uttarakhand | North | Adventure | Winter | Skiing | 16000 | 4.6 |
9 | 1 | Manali | Himachal_Pradesh | North | HillStation | Summer | Skiing | 15000 | 4.7 |
10 | 14 | Shillong | Meghalaya | East | HillStation | Summer | Waterfalls | 15000 | 4.3 |
4. PROC MEANS – Average cost and rating
Purpose: To find mean, min, and max values for cost and rating
proc means data=vacation_places_india mean min max;
var Avg_Cost_Per_Person Rating;
run;
Output:
The MEANS Procedure
Variable | Mean | Minimum | Maximum |
---|---|---|---|
Avg_Cost_Per_Person Rating | 14000.00 4.4370370 | 9000.00 4.0000000 | 25000.00 4.9000000 |
5. PROC FREQ – Frequency of vacation types
Purpose: To calculate frequency of each vacation type (e.g., HillStation, Heritage)
proc freq data=vacation_places_india;
tables Type;
run;
Output:
The FREQ Procedure
Type | Frequency | Percent | Cumulative Frequency | Cumulative Percent |
---|---|---|---|---|
Adventure | 2 | 7.41 | 2 | 7.41 |
Backwater | 1 | 3.70 | 3 | 11.11 |
Beach | 3 | 11.11 | 6 | 22.22 |
Coastal | 1 | 3.70 | 7 | 25.93 |
Heritage | 7 | 25.93 | 14 | 51.85 |
HillStation | 10 | 37.04 | 24 | 88.89 |
Spiritual | 3 | 11.11 | 27 | 100.00 |
6. PROC UNIVARIATE – Distribution of ratings
Purpose: To analyze the distribution and shape of the Rating variable
proc univariate data=vacation_places_india;
var Rating;
run;
Output:
The UNIVARIATE Procedure
Variable: Rating
Moments | |||
---|---|---|---|
N | 27 | Sum Weights | 27 |
Mean | 4.43703704 | Sum Observations | 119.8 |
Std Deviation | 0.24984326 | Variance | 0.06242165 |
Skewness | 0.11798908 | Kurtosis | -0.9444171 |
Uncorrected SS | 533.18 | Corrected SS | 1.62296296 |
Coeff Variation | 5.63085802 | Std Error Mean | 0.04808236 |
Basic Statistical Measures | |||
---|---|---|---|
Location | Variability | ||
Mean | 4.437037 | Std Deviation | 0.24984 |
Median | 4.400000 | Variance | 0.06242 |
Mode | 4.300000 | Range | 0.90000 |
Interquartile Range | 0.40000 |
Note: The mode displayed is the smallest of 2 modes with a count of 4.
Tests for Location: Mu0=0 | ||||
---|---|---|---|---|
Test | Statistic | p Value | ||
Student's t | t | 92.27994 | Pr > |t| | <.0001 |
Sign | M | 13.5 | Pr >= |M| | <.0001 |
Signed Rank | S | 189 | Pr >= |S| | <.0001 |
Quantiles (Definition 5) | |
---|---|
Level | Quantile |
100% Max | 4.9 |
99% | 4.9 |
95% | 4.8 |
90% | 4.8 |
75% Q3 | 4.6 |
50% Median | 4.4 |
25% Q1 | 4.2 |
10% | 4.1 |
5% | 4.1 |
1% | 4.0 |
0% Min | 4.0 |
Extreme Observations | |||
---|---|---|---|
Lowest | Highest | ||
Value | Obs | Value | Obs |
4.0 | 23 | 4.7 | 16 |
4.1 | 26 | 4.8 | 2 |
4.1 | 20 | 4.8 | 9 |
4.1 | 15 | 4.8 | 18 |
4.2 | 25 | 4.9 | 11 |
7. PROC TRANSPOSE – Transpose data for comparison
Purpose: To restructure the dataset for comparing ratings across regions
proc transpose data=vacation_places_india out=transposed_rating;
id Region;
var Rating;
by Type;
run;
proc print;run;
Output:
Obs | Type | _NAME_ | North | West | East | South | UT | Central |
---|---|---|---|---|---|---|---|---|
1 | HillStation | Rating | 4.7 | . | . | . | . | . |
2 | Beach | Rating | . | 4.8 | . | . | . | . |
3 | Heritage | Rating | . | 4.5 | . | . | . | . |
4 | Heritage | Rating | . | 4.3 | . | . | . | . |
5 | Spiritual | Rating | 4.6 | . | . | . | . | . |
6 | Beach | Rating | . | . | . | . | 4.8 | . |
7 | Spiritual | Rating | 4.5 | . | . | . | . | . |
8 | Adventure | Rating | 4.9 | . | . | . | . | . |
9 | Heritage | Rating | . | . | . | 4.2 | . | . |
10 | Backwater | Rating | . | . | . | 4.4 | . | . |
11 | HillStation | Rating | . | . | 4.3 | . | . | . |
12 | Heritage | Rating | 4.7 | . | . | 4.1 | . | . |
13 | Coastal | Rating | . | . | . | 4.2 | . | . |
14 | HillStation | Rating | 4.8 | . | . | . | . | . |
15 | Beach | Rating | . | . | 4.3 | . | . | . |
16 | Heritage | Rating | . | . | . | 4.1 | . | . |
17 | Adventure | Rating | 4.6 | . | . | . | . | . |
18 | Spiritual | Rating | . | . | . | 4.4 | . | . |
19 | Heritage | Rating | . | . | . | . | . | 4 |
8. PROC SGPLOT – Plot Cost vs Rating
Purpose: To visualize the relationship between cost and rating grouped by vacation type
proc sgplot data=vacation_places_india;
scatter x=Avg_Cost_Per_Person y=Rating / group=Type;
title "Scatter Plot of Cost vs Rating by Vacation Type";
run;
Output:
9. PROC SQL – Multiple tasks
a. Top 5 rated vacation places
Purpose: To get top 5 vacation places by rating using SQL
proc sql outobs=5;
select Name, State, Type, Rating
from vacation_places_india
order by Rating desc;
quit;
Output:
Name | State | Type | Rating |
---|---|---|---|
Leh | Ladakh | Adventure | 4.9 |
Goa | Goa | Beach | 4.8 |
Andaman | Islands | Beach | 4.8 |
Gulmarg | Jammu_and_Kashmir | HillStation | 4.8 |
Manali | Himachal_Pradesh | HillStation | 4.7 |
b. Count places per state
Purpose: To count how many vacation spots exist per state
proc sql;
select State, count(*) as Place_Count
from vacation_places_india
group by State
order by Place_Count desc;
quit;
Output:
State | Place_Count |
---|---|
Tamil_Nadu | 4 |
Karnataka | 3 |
Rajasthan | 3 |
Kerala | 2 |
Uttar_Pradesh | 2 |
Uttarakhand | 2 |
Ladakh | 1 |
Islands | 1 |
Sikkim | 1 |
Odisha | 1 |
Meghalaya | 1 |
Maharashtra | 1 |
Goa | 1 |
Himachal_Pradesh | 1 |
Jammu_and_Kashmir | 1 |
Madhya_Pradesh | 1 |
West_Bengal | 1 |
10. MACROS – Automate analysis
a. Macro to display top N vacation places by rating
Purpose: Reusable macro to get top N vacation spots by rating
%macro top_places(n=5);
proc sql outobs=&n;
title "Top &n Rated Vacation Places";
select Name, State, Rating
from vacation_places_india
order by Rating desc;
quit;
%mend;
%top_places(n=10);
Output:
Top 10 Rated Vacation Places
Name | State | Rating |
---|---|---|
Leh | Ladakh | 4.9 |
Goa | Goa | 4.8 |
Andaman | Islands | 4.8 |
Gulmarg | Jammu_and_Kashmir | 4.8 |
Manali | Himachal_Pradesh | 4.7 |
Agra | Uttar_Pradesh | 4.7 |
Ooty | Tamil_Nadu | 4.6 |
Auli | Uttarakhand | 4.6 |
Rishikesh | Uttarakhand | 4.6 |
Sikkim | Sikkim | 4.5 |
b. Macro to show places by type
Purpose: To filter and print vacation places of a specific type
%macro show_by_type(place_type);
proc print data=vacation_places_india;
where Type="&place_type";
title "Places of Type: &place_type";
run;
%mend;
%show_by_type(HillStation);
Output:
Places of Type: HillStation
Obs | Place_ID | Name | State | Region | Type | Ideal_Season | Popular_Activity | Avg_Cost_Per_Person | Rating |
---|---|---|---|---|---|---|---|---|---|
1 | 1 | Manali | Himachal_Pradesh | North | HillStation | Summer | Skiing | 15000 | 4.7 |
4 | 4 | Darjeeling | West_Bengal | East | HillStation | Summer | Toy_Train | 12000 | 4.4 |
5 | 5 | Ooty | Tamil_Nadu | South | HillStation | Summer | Botanical_Garden | 13000 | 4.6 |
6 | 6 | Munnar | Kerala | South | HillStation | Monsoon | Tea_Estate_Tour | 14000 | 4.5 |
14 | 14 | Shillong | Meghalaya | East | HillStation | Summer | Waterfalls | 15000 | 4.3 |
18 | 18 | Gulmarg | Jammu_and_Kashmir | North | HillStation | Winter | Skiing | 18000 | 4.8 |
24 | 24 | Sikkim | Sikkim | East | HillStation | Summer | Trekking | 17000 | 4.5 |
25 | 25 | Mount_Abu | Rajasthan | West | HillStation | Summer | Lake_Boating | 12000 | 4.2 |
26 | 26 | Lonavala | Maharashtra | West | HillStation | Monsoon | Nature_Walk | 9000 | 4.1 |
27 | 27 | Coorg | Karnataka | South | HillStation | Monsoon | Coffee_Plantation | 13000 | 4.3 |
%show_by_type(Heritage);
Output:
Places of Type: Heritage
Obs | Place_ID | Name | State | Region | Type | Ideal_Season | Popular_Activity | Avg_Cost_Per_Person | Rating |
---|---|---|---|---|---|---|---|---|---|
3 | 3 | Jaipur | Rajasthan | West | Heritage | Winter | Fort_Visit | 14000 | 4.5 |
7 | 7 | Udaipur | Rajasthan | West | Heritage | Winter | Lake_Tour | 16000 | 4.3 |
12 | 12 | Mysore | Karnataka | South | Heritage | Winter | Palace_Visit | 10000 | 4.2 |
15 | 15 | Hampi | Karnataka | South | Heritage | Winter | Ruins_Tour | 14000 | 4.1 |
16 | 16 | Agra | Uttar_Pradesh | North | Heritage | Winter | Taj_Mahal | 12000 | 4.7 |
20 | 20 | Mahabalipuram | Tamil_Nadu | South | Heritage | Winter | Temple_Sculptures | 11000 | 4.1 |
23 | 23 | Khajuraho | Madhya_Pradesh | Central | Heritage | Winter | Erotic_Sculptures | 14000 | 4.0 |
- Get link
- X
- Other Apps
Comments
Post a Comment