Tuesday, 22 July 2025

247.IN-DEPTH ANALYSIS OF GOVERNMENT BUS DEPOTS ACROSS VARIOUS INDIAN STATES USING PROC PRINT | PROC SORT | PROC FREQ | PROC MEANS | PROC SQL | ADVANCED MACROS | IN SAS FOR STRATEGIC TRANSPORTATION INSIGHTS AND INFRASTRUCTURE OPTIMIZATION

IN-DEPTH ANALYSIS OF GOVERNMENT BUS DEPOTS ACROSS VARIOUS INDIAN STATES USING PROC PRINT | PROC SORT | PROC FREQ | PROC MEANS | PROC SQL | ADVANCED MACROS | IN SAS FOR STRATEGIC TRANSPORTATION INSIGHTS AND INFRASTRUCTURE OPTIMIZATION

/*Creating a unique dataset about various Government Bus Depots across different Indian states*/

1. DATA CREATION: GOVT BUS DEPOTS DATASET

options nocenter;

data bus_depots;

    length Depot_Name $20 State $15 Region $12  Depot_Manager $15 Fuel_Type $10;

    input Depot_ID  Depot_Name $ State $ Region $ No_of_Buses Depot_Manager $                 Daily_Passenger_Count  Fuel_Type $  Depot_Area_sqkm Year_Of_Establishment;    

    datalines;

101 HyderabadDepot Telangana South 145 Ramesh 21000 Diesel 3.5 1990

102 SecunderabadDepot Telangana South 130 Suresh 19500 CNG 3.0 1985

103 ChennaiDepot TamilNadu South 180 Karthik 28000 Diesel 4.0 1980

104 MaduraiDepot TamilNadu South 90 Rajan 12500 Diesel 2.8 1995

105 BangaloreDepot Karnataka South 200 Ravi 32000 CNG 4.5 1988

106 MysoreDepot Karnataka South 120 Anand 16000 Diesel 3.2 1993

107 KochiDepot Kerala South 100 Manoj 14000 Diesel 3.0 1992

108 TrivandrumDepot Kerala South 85 Vinod 12000 CNG 2.7 1996

109 MumbaiDepot Maharashtra West 220 Aditya 33000 Diesel 5.0 1982

110 PuneDepot Maharashtra West 190 Nikhil 29000 Electric 4.8 1987

111 AhmedabadDepot Gujarat West 175 Bharat 27500 Diesel 4.0 1989

112 SuratDepot Gujarat West 160 Hemant 26000 Diesel 3.9 1991

113 JaipurDepot Rajasthan North 155 Harish 24000 Diesel 4.1 1990

114 UdaipurDepot Rajasthan North 100 Nilesh 14500 Diesel 3.5 1995

115 LucknowDepot UP North 210 Pankaj 35000 CNG 4.9 1986

116 KanpurDepot UP North 200 Amit 34000 CNG 4.8 1984

117 DelhiDepot Delhi North 300 Kapil 45000 CNG 5.5 1980

118 PatnaDepot Bihar East 140 Alok 20000 Diesel 3.4 1988

119 RanchiDepot Jharkhand East 135 Ritesh 19000 Diesel 3.2 1992

120 BhubaneswarDepot Odisha East 130 Sanjay 18500 Diesel 3.3 1990

121 KolkataDepot WB East 250 Arindam 40000 Diesel 5.1 1981

122 GuwahatiDepot Assam North-East 110 Prakash 17000 Diesel 3.7 1993

123 ShillongDepot Meghalaya North-East 90 Ranjit 15000 Diesel 3.2 1994

124 IndoreDepot MP Central 160 Rohit 26000 Diesel 4.0 1985

125 BhopalDepot MP Central 165 Deepak 26500 CNG 4.1 1986

;

run;

proc print;run;

Output:

ObsDepot_NameStateRegionDepot_ManagerFuel_TypeDepot_IDNo_of_BusesDaily_Passenger_CountDepot_Area_sqkmYear_Of_Establishment
1HyderabadDepotTelanganaSouthRameshDiesel101145210003.51990
2SecunderabadDepotTelanganaSouthSureshCNG102130195003.01985
3ChennaiDepotTamilNaduSouthKarthikDiesel103180280004.01980
4MaduraiDepotTamilNaduSouthRajanDiesel10490125002.81995
5BangaloreDepotKarnatakaSouthRaviCNG105200320004.51988
6MysoreDepotKarnatakaSouthAnandDiesel106120160003.21993
7KochiDepotKeralaSouthManojDiesel107100140003.01992
8TrivandrumDepotKeralaSouthVinodCNG10885120002.71996
9MumbaiDepotMaharashtraWestAdityaDiesel109220330005.01982
10PuneDepotMaharashtraWestNikhilElectric110190290004.81987
11AhmedabadDepotGujaratWestBharatDiesel111175275004.01989
12SuratDepotGujaratWestHemantDiesel112160260003.91991
13JaipurDepotRajasthanNorthHarishDiesel113155240004.11990
14UdaipurDepotRajasthanNorthNileshDiesel114100145003.51995
15LucknowDepotUPNorthPankajCNG115210350004.91986
16KanpurDepotUPNorthAmitCNG116200340004.81984
17DelhiDepotDelhiNorthKapilCNG117300450005.51980
18PatnaDepotBiharEastAlokDiesel118140200003.41988
19RanchiDepotJharkhandEastRiteshDiesel119135190003.21992
20BhubaneswarDepotOdishaEastSanjayDiesel120130185003.31990
21KolkataDepotWBEastArindamDiesel121250400005.11981
22GuwahatiDepotAssamNorth-EastPrakashDiesel122110170003.71993
23ShillongDepotMeghalayaNorth-EastRanjitDiesel12390150003.21994
24IndoreDepotMPCentralRohitDiesel124160260004.01985
25BhopalDepotMPCentralDeepakCNG125165265004.11986


2. PROC PRINT – View 10 Obs Data

proc print data=bus_depots (obs=10) noobs label;

    title  "First 10 of Government Bus Depots in India";

run;

Output:

First 10 of Government Bus Depots in India

Depot_NameStateRegionDepot_ManagerFuel_TypeDepot_IDNo_of_BusesDaily_Passenger_CountDepot_Area_sqkmYear_Of_Establishment
HyderabadDepotTelanganaSouthRameshDiesel101145210003.51990
SecunderabadDepotTelanganaSouthSureshCNG102130195003.01985
ChennaiDepotTamilNaduSouthKarthikDiesel103180280004.01980
MaduraiDepotTamilNaduSouthRajanDiesel10490125002.81995
BangaloreDepotKarnatakaSouthRaviCNG105200320004.51988
MysoreDepotKarnatakaSouthAnandDiesel106120160003.21993
KochiDepotKeralaSouthManojDiesel107100140003.01992
TrivandrumDepotKeralaSouthVinodCNG10885120002.71996
MumbaiDepotMaharashtraWestAdityaDiesel109220330005.01982
PuneDepotMaharashtraWestNikhilElectric110190290004.81987

3. PROC SORT – Sorting by State and Buses

proc sort data=bus_depots out=sorted_depots;

    by descending No_of_Buses;

run;


proc print data=sorted_depots;

    title "Depots Sorted by Number of Buses (Descending)";

run;

Output:

Depots Sorted by Number of Buses (Descending)

ObsDepot_NameStateRegionDepot_ManagerFuel_TypeDepot_IDNo_of_BusesDaily_Passenger_CountDepot_Area_sqkmYear_Of_Establishment
1DelhiDepotDelhiNorthKapilCNG117300450005.51980
2KolkataDepotWBEastArindamDiesel121250400005.11981
3MumbaiDepotMaharashtraWestAdityaDiesel109220330005.01982
4LucknowDepotUPNorthPankajCNG115210350004.91986
5BangaloreDepotKarnatakaSouthRaviCNG105200320004.51988
6KanpurDepotUPNorthAmitCNG116200340004.81984
7PuneDepotMaharashtraWestNikhilElectric110190290004.81987
8ChennaiDepotTamilNaduSouthKarthikDiesel103180280004.01980
9AhmedabadDepotGujaratWestBharatDiesel111175275004.01989
10BhopalDepotMPCentralDeepakCNG125165265004.11986
11SuratDepotGujaratWestHemantDiesel112160260003.91991
12IndoreDepotMPCentralRohitDiesel124160260004.01985
13JaipurDepotRajasthanNorthHarishDiesel113155240004.11990
14HyderabadDepotTelanganaSouthRameshDiesel101145210003.51990
15PatnaDepotBiharEastAlokDiesel118140200003.41988
16RanchiDepotJharkhandEastRiteshDiesel119135190003.21992
17SecunderabadDepotTelanganaSouthSureshCNG102130195003.01985
18BhubaneswarDepotOdishaEastSanjayDiesel120130185003.31990
19MysoreDepotKarnatakaSouthAnandDiesel106120160003.21993
20GuwahatiDepotAssamNorth-EastPrakashDiesel122110170003.71993
21KochiDepotKeralaSouthManojDiesel107100140003.01992
22UdaipurDepotRajasthanNorthNileshDiesel114100145003.51995
23MaduraiDepotTamilNaduSouthRajanDiesel10490125002.81995
24ShillongDepotMeghalayaNorth-EastRanjitDiesel12390150003.21994
25TrivandrumDepotKeralaSouthVinodCNG10885120002.71996

4. PROC FREQ – Frequency of Regions and Fuel Types

proc freq data=bus_depots;

    tables Region Fuel_Type / nocum nopercent;

    title "Frequency Distribution of Depots by Region and Fuel Type";

run;

Output:

Frequency Distribution of Depots by Region and Fuel Type

The FREQ Procedure

RegionFrequency
Central2
East4
North5
North-East2
South8
West4
Fuel_TypeFrequency
CNG7
Diesel17
Electric1

5. PROC MEANS – Summary Statistics

proc means data=bus_depots mean median min max maxdec=2;

    var No_of_Buses Daily_Passenger_Count Depot_Area_sqkm;

    title "Descriptive Statistics for Key Numerical Metrics";

run;

Output:

Descriptive Statistics for Key Numerical Metrics

The MEANS Procedure

VariableMeanMedianMinimumMaximum
No_of_Buses
Daily_Passenger_Count
Depot_Area_sqkm
157.60
24200.00
3.89
155.00
24000.00
3.90
85.00
12000.00
2.70
300.00
45000.00
5.50

6. PROC SQL – Queries for Deeper Insights

a) Top 5 depots by passengers

proc sql outobs=5;

    title "Top 5 Bus Depots by Daily Passenger Count";

    select Depot_Name, State, Daily_Passenger_Count 

    from bus_depots 

    order by Daily_Passenger_Count desc;

quit;

Output:

Top 5 Bus Depots by Daily Passenger Count

Depot_NameStateDaily_Passenger_Count
DelhiDepotDelhi45000
KolkataDepotWB40000
LucknowDepotUP35000
KanpurDepotUP34000
MumbaiDepotMaharashtra33000

b) Average buses per region

proc sql;

    title "Average Number of Buses by Region";

    select Region, avg(No_of_Buses) as Avg_Buses

    from bus_depots

    group by Region;

quit;

Output:

Average Number of Buses by Region

RegionAvg_Buses
Central162.5
East163.75
North193
North-East100
South131.25
West186.25

c) Electric or CNG-based depots

proc sql;

    title "List of Eco-friendly Depots (Electric or CNG)";

    select Depot_Name, Fuel_Type, State 

    from bus_depots

    where Fuel_Type in ('CNG', 'Electric');

quit;

Output:

List of Eco-friendly Depots (Electric or CNG)

Depot_NameFuel_TypeState
SecunderabadDepotCNGTelangana
BangaloreDepotCNGKarnataka
TrivandrumDepotCNGKerala
PuneDepotElectricMaharashtra
LucknowDepotCNGUP
KanpurDepotCNGUP
DelhiDepotCNGDelhi
BhopalDepotCNGMP

7. SAS MACRO – Automate State-Wise Report Generation

%macro StateReport(state);

    proc print data=bus_depots;

        where State = "&state";

        title "Bus Depot Report for &state";

    run;

    

    proc means data=bus_depots;

        where State = "&state";

        var No_of_Buses Daily_Passenger_Count;

        title "Statistical Summary for &state Depots";

    run;

%mend;


%StateReport(Karnataka)

Output:

Bus Depot Report for Karnataka

ObsDepot_NameStateRegionDepot_ManagerFuel_TypeDepot_IDNo_of_BusesDaily_Passenger_CountDepot_Area_sqkmYear_Of_Establishment
5BangaloreDepotKarnatakaSouthRaviCNG105200320004.51988
6MysoreDepotKarnatakaSouthAnandDiesel106120160003.21993

Statistical Summary for Karnataka Depots

The MEANS Procedure

VariableNMeanStd DevMinimumMaximum
No_of_Buses
Daily_Passenger_Count
2
2
160.0000000
24000.00
56.5685425
11313.71
120.0000000
16000.00
200.0000000
32000.00

%StateReport(Maharashtra)

Output:

Bus Depot Report for Maharashtra

ObsDepot_NameStateRegionDepot_ManagerFuel_TypeDepot_IDNo_of_BusesDaily_Passenger_CountDepot_Area_sqkmYear_Of_Establishment
9MumbaiDepotMaharashtraWestAdityaDiesel109220330005.01982
10PuneDepotMaharashtraWestNikhilElectric110190290004.81987

Statistical Summary for Maharashtra Depots

The MEANS Procedure

VariableNMeanStd DevMinimumMaximum
No_of_Buses
Daily_Passenger_Count
2
2
205.0000000
31000.00
21.2132034
2828.43
190.0000000
29000.00
220.0000000
33000.00

8. Advanced Use Case: Depots Established Before 1990

data pre90;

    set bus_depots;

    if Year_Of_Establishment < 1990;

run;


proc print data=pre90;

    title "Depots Established Before 1990";

run;

Output:

Depots Established Before 1990

ObsDepot_NameStateRegionDepot_ManagerFuel_TypeDepot_IDNo_of_BusesDaily_Passenger_CountDepot_Area_sqkmYear_Of_Establishment
1SecunderabadDepotTelanganaSouthSureshCNG102130195003.01985
2ChennaiDepotTamilNaduSouthKarthikDiesel103180280004.01980
3BangaloreDepotKarnatakaSouthRaviCNG105200320004.51988
4MumbaiDepotMaharashtraWestAdityaDiesel109220330005.01982
5PuneDepotMaharashtraWestNikhilElectric110190290004.81987
6AhmedabadDepotGujaratWestBharatDiesel111175275004.01989
7LucknowDepotUPNorthPankajCNG115210350004.91986
8KanpurDepotUPNorthAmitCNG116200340004.81984
9DelhiDepotDelhiNorthKapilCNG117300450005.51980
10PatnaDepotBiharEastAlokDiesel118140200003.41988
11KolkataDepotWBEastArindamDiesel121250400005.11981
12IndoreDepotMPCentralRohitDiesel124160260004.01985
13BhopalDepotMPCentralDeepakCNG125165265004.1198

9. Additional Logic: High Density Depots

data high_density;

    set bus_depots;

    Passenger_Density = Daily_Passenger_Count / Depot_Area_sqkm;

    if Passenger_Density > 6000;

run;


proc print data=high_density;

    title "High-Density Depots Based on Area and Passenger Footfall";

run;

Output:

High-Density Depots Based on Area and Passenger Footfall

ObsDepot_NameStateRegionDepot_ManagerFuel_TypeDepot_IDNo_of_BusesDaily_Passenger_CountDepot_Area_sqkmYear_Of_EstablishmentPassenger_Density
1SecunderabadDepotTelanganaSouthSureshCNG102130195003.019856500.00
2ChennaiDepotTamilNaduSouthKarthikDiesel103180280004.019807000.00
3BangaloreDepotKarnatakaSouthRaviCNG105200320004.519887111.11
4MumbaiDepotMaharashtraWestAdityaDiesel109220330005.019826600.00
5PuneDepotMaharashtraWestNikhilElectric110190290004.819876041.67
6AhmedabadDepotGujaratWestBharatDiesel111175275004.019896875.00
7SuratDepotGujaratWestHemantDiesel112160260003.919916666.67
8LucknowDepotUPNorthPankajCNG115210350004.919867142.86
9KanpurDepotUPNorthAmitCNG116200340004.819847083.33
10DelhiDepotDelhiNorthKapilCNG117300450005.519808181.82
11KolkataDepotWBEastArindamDiesel121250400005.119817843.14
12IndoreDepotMPCentralRohitDiesel124160260004.019856500.00
13BhopalDepotMPCentralDeepakCNG125165265004.119866463.41

10. Macro with SQL: Generate Top Depot by Each Region

%macro topDepotByRegion;

    proc sql noprint;

        select distinct Region into :regions separated by ',' 

        from bus_depots;

    quit;


    %let count = %sysfunc(countw(%bquote(&regions), %str(,)));


    %do i = 1 %to &count;

        %let reg = %scan(%bquote(&regions), &i, %str(,));


        proc sql;

            title "Top Depot in &reg Region by Daily Passenger Count";

            select Depot_Name, Region, Daily_Passenger_Count 

            from bus_depots

            where Region = "&reg"

              and Daily_Passenger_Count = 

                  (select max(Daily_Passenger_Count)

                   from bus_depots 

                   where Region = "&reg");

        quit;


    %end;

%mend;


%topDepotByRegion;

Output:

Top Depot in Central Region by Daily Passenger Count

Depot_NameRegionDaily_Passenger_Count
BhopalDepotCentral26500

Top Depot in East Region by Daily Passenger Count

Depot_NameRegionDaily_Passenger_Count
KolkataDepotEast40000

Top Depot in North Region by Daily Passenger Count

Depot_NameRegionDaily_Passenger_Count
DelhiDepotNorth45000

Top Depot in North-East Region by Daily Passenger Count

Depot_NameRegionDaily_Passenger_Count
GuwahatiDepotNorth-East17000

Top Depot in South Region by Daily Passenger Count

Depot_NameRegionDaily_Passenger_Count
BangaloreDepotSouth32000

Top Depot in West Region by Daily Passenger Count

Depot_NameRegionDaily_Passenger_Count
MumbaiDepotWest33000




To Visit My Previous First. Last. Statements:Click Here
To Visit My Previous Set Where Statements:Click Here
To Visit My Previous Online Gaming Dataset:Click Here
To Visit My Previous Length Statement Using In Many Ways:Click Here





--->PLEASE FOLLOW OUR BLOG FOR MORE INFORMATION.
--->PLEASE DO COMMENTS AND SHARE OUR BLOG.

PLEASE FOLLOW OUR TELEGRAM CHANNEL CLICK HERE

PLEASE FOLLOW OUR FACEBOOK PAGE  CLICK HERE

PLEASE FOLLOW OUR INSTAGRAM PAGE CLICK HERE


No comments:

Post a Comment