718.Can We Design, Debug, Detect Fraud, And Optimize A Smart Parking System Using Advanced SAS Programming Techniques?

Smart Parking Analytics Engine: From Data Errors To Revenue Control

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

HERE IN THIS PROJECT WE USED THESE SAS STATEMENTS —DATA STEP | SET | IF-THEN-ELSE | PROC PRINT | PROC SQL | SELECT | SUM | COUNT | GROUP BY | LEFT JOIN | PROC SORT | MERGE | PROC APPEND | PROC TRANSPOSE | PROC DATASETS DELETE | MACRO | RUN | QUIT

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Introduction

In today’s urban environments, smart parking systems play a critical role in reducing traffic congestion, fuel consumption, and driver frustration. Cities are investing in IoT-enabled parking sensors, real-time occupancy dashboards, automated billing, and predictive analytics to manage parking spaces efficiently.

·  Data creation and simulation

·  Fraud detection logic

·  Data validation and debugging

·  Macro automation

·  Performance analytics

·  Error correction and QC

In this project, we will:

·  Create a dataset with more than 15 observations

·  Intentionally introduce data errors

·  Debug and correct those errors

·  Apply DATA step, PROC SQL, and MACROS

·  Use date functions (MDY, INTCK, INTNX)

·  Use SET, MERGE, APPEND, TRANSPOSE

·  Apply numeric and character functions

·  Use PROC DATASETS DELETE

·  Build fraud detection logic

This project is not just about dataset creation. It simulates a real-world Smart City Analytics Platform using SAS programming concepts including:

·  DATA step processing

·  PROC SQL

·  Macros

·  Date functions (MDY, INTCK, INTNX)

·  Character functions (STRIP, TRIM, PROPCASE, UPCASE, LOWCASE, CAT, CATX)

·  Numeric functions (ROUND, ABS, COALESCE)

·  SET, MERGE, APPEND, TRANSPOSE

·  PROC DATASETS DELETE

·  Fraud scoring models

Table Of Contents

1.     Raw Dataset With Intentional Errors

2.     Corrected Full Dataset Code

3.     Fraud Detection Macro

4.     Append Operation (PROC APPEND)

5.     Merge Operation (DATA Step MERGE)

6.     Transpose Operation (PROC TRANSPOSE)

7.     Dataset Deletion (PROC DATASETS DELETE)

8.     Revenue Analysis Using PROC SQL

9.     Sensor-Level Dataset Creation

10.  Payment Transaction Dataset Creation

11.  Revenue Reconciliation Logic (SQL Join)

12.  Revenue Leak Fraud Indicator

13.  Advanced Fraud Scoring Model

14.  Efficiency KPI Framework

15.  Real-Time Utilization Engine

16.  Predictive Maintenance Engine

17.  Data Quality Validation Macro

18.  Audit Trail System

19.  Performance Optimization Using Indexing

20.  20 Key Points

21.  Summary

22.  Conclusion

BUSINESS CONTEXT

Imagine a metropolitan smart city like:

·       Hyderabad

·       Mumbai

·       Delhi

·       Bengaluru

·       Chennai

·       Pune

Each city operates hundreds of smart parking lots equipped with:

·       IoT sensors per slot

·       Digital payment systems

·       Mobile booking apps

·       Automated revenue collection

·       Maintenance scheduling systems

However, real-world challenges exist:

1.     Occupancy manipulation

2.     Revenue leakage

3.     Cash skimming

4.     Sensor malfunction

5.     Ghost billing

6.     System downtime

7.     Payment mismatch

8.     Data inconsistency

9.     Fraudulent manual overrides

10.  Poor maintenance tracking

Municipal corporations require:

·       Accurate utilization metrics

·       Transparent revenue reporting

·       Fraud monitoring system

·       Operational efficiency KPIs

·       Predictive analytics

·       Automated validation

1. RAW DATASET WITH INTENTIONAL ERRORS

data smart_parking_raw;

length Parking_ID $5 City $20 Util_Class $15;

format Install_Date Last_Maint_Date date9.;

input Parking_ID $ City $ Slots_Total Occupancy_Rate Avg_Search_Time Revenue 

      Efficiency_Score Install_Date :date9. Last_Maint_Date :date9.;

datalines;

P001 Hyderabad 100 85 5 15000 92 01JAN2024 01MAR2024

P002 mumbai 200 110 4 30000 105 15FEB2024 01APR2024

P003 DELHI 150 75 6 -2000 88 01MAR2024 10MAR2024

P004 Bengaluru 120 . 7 18000 90 05JAN2024 01FEB2024

P005 Chennai 80 95 3 12000 95 01APR2024 01APR2024

P006 Pune 60 45 8 8000 70 01JAN2024 15JAN2024

P007 Hyderabad 90 100 2 20000 99 01JAN2024 01FEB2024

P008 Mumbai 110 60 9 17000 85 01MAR2024 01MAR2024

P009 Delhi 140 70 10 21000 87 01JAN2024 01APR2024

P010 Bengaluru 130 85 6 22000 93 01FEB2024 01MAR2024

P011 Chennai 95 50 12 5000 60 01JAN2024 01JAN2024

P012 Pune 75 40 15 4000 55 01JAN2024 10JAN2024

P013 Hyderabad 200 180 3 50000 98 01JAN2024 01APR2024

P014 Mumbai 100 0 20 0 20 01JAN2024 01JAN2024

P015 Delhi 160 150 4 45000 96 01JAN2024 01MAR2024

;

run;

proc print data=smart_parking_raw;

run;

OUTPUT:

ObsParking_IDCityUtil_ClassInstall_DateLast_Maint_DateSlots_TotalOccupancy_RateAvg_Search_TimeRevenueEfficiency_Score
1P001Hyderabad 01JAN202401MAR20241008551500092
2P002mumbai 15FEB202401APR2024200110430000105
3P003DELHI 01MAR202410MAR2024150756-200088
4P004Bengaluru 05JAN202401FEB2024120.71800090
5P005Chennai 01APR202401APR2024809531200095
6P006Pune 01JAN202415JAN202460458800070
7P007Hyderabad 01JAN202401FEB20249010022000099
8P008Mumbai 01MAR202401MAR20241106091700085
9P009Delhi 01JAN202401APR202414070102100087
10P010Bengaluru 01FEB202401MAR20241308562200093
11P011Chennai 01JAN202401JAN2024955012500060
12P012Pune 01JAN202410JAN2024754015400055
13P013Hyderabad 01JAN202401APR202420018035000098
14P014Mumbai 01JAN202401JAN2024100020020
15P015Delhi 01JAN202401MAR202416015044500096

Intentional Errors Introduced

Error

Explanation

Occupancy > Slots

P002, P005

Efficiency > 100

P002

Negative Revenue

P003

Missing Occupancy

P004

100% Occupancy unrealistic

P007

Zero revenue but slots exist

P014

Mixed case city names

mumbai, DELHI

Same Install & Maintenance date

Several records

2. CORRECTED FULL DATASET CODE

data smart_parking_clean;

set smart_parking_raw;

City = propcase(strip(City));

Occupied_Slots = round((Occupancy_Rate/100) * Slots_Total);

if Occupied_Slots > Slots_Total then Occupied_Slots = Slots_Total;

if Revenue < 0 then Revenue = 0;

if Efficiency_Score > 100 then Efficiency_Score = 100;

if missing(Occupancy_Rate) then Occupancy_Rate = 0;

Utilization_Percent = round((Occupied_Slots/Slots_Total)*100,0.1);

if Utilization_Percent >= 85 then Util_Class="High";

else if Utilization_Percent >=60 then Util_Class="Medium";

else Util_Class="Low";

Parking_Name = catx("_",upcase(City),Parking_ID);

Months_Operational = intck('month',Install_Date,today());

Next_Maintenance = intnx('month',Last_Maint_Date,3,'same');

run;

proc print data=smart_parking_clean;

run;

OUTPUT:

ObsParking_IDCityUtil_ClassInstall_DateLast_Maint_DateSlots_TotalOccupancy_RateAvg_Search_TimeRevenueEfficiency_ScoreOccupied_SlotsUtilization_PercentParking_NameMonths_OperationalNext_Maintenance
1P001HyderabadHigh01JAN202401MAR202410085515000928585.0HYDERABAD_P0012623528
2P002MumbaiHigh15FEB202401APR2024200110430000100200100.0MUMBAI_P0022523558
3P003DelhiMedium01MAR202410MAR202415075608811375.3DELHI_P0032423537
4P004BengaluruLow05JAN202401FEB2024120071800090..BENGALURU_P0042623497
5P005ChennaiHigh01APR202401APR20248095312000957695.0CHENNAI_P0052323558
6P006PuneLow01JAN202415JAN2024604588000702745.0PUNE_P0062623481
7P007HyderabadHigh01JAN202401FEB2024901002200009990100.0HYDERABAD_P0072623497
8P008MumbaiMedium01MAR202401MAR202411060917000856660.0MUMBAI_P0082423528
9P009DelhiMedium01JAN202401APR2024140701021000879870.0DELHI_P0092623558
10P010BengaluruHigh01FEB202401MAR2024130856220009311185.4BENGALURU_P0102523528
11P011ChennaiLow01JAN202401JAN20249550125000604850.5CHENNAI_P0112623467
12P012PuneLow01JAN202410JAN20247540154000553040.0PUNE_P0122623476
13P013HyderabadHigh01JAN202401APR202420018035000098200100.0HYDERABAD_P0132623558
14P014MumbaiLow01JAN202401JAN202410002002000.0MUMBAI_P0142623467
15P015DelhiHigh01JAN202401MAR202416015044500096160100.0DELHI_P0152623528

set smart_parking_raw;

Reads previous dataset into new dataset.

propcase(strip(City));\

·       strip( ) removes spaces

·       propcase( ) standardizes case

round()

Prevents decimal slot calculation.

intck()

Counts number of months between two dates.

intnx()

Adds 3 months for next maintenance.

3. FRAUD DETECTION MACRO

%macro fraud_detection(ds);

data fraud_flagged;

set &ds;

length Fraud_Flag $10;

if Revenue > 40000 and Utilization_Percent < 50 then Fraud_Flag="Yes";

else if Occupied_Slots = Slots_Total and Avg_Search_Time < 2 then Fraud_Flag="Yes";

else Fraud_Flag="No";

run;

proc print data=fraud_flagged;

run;

%mend;


%fraud_detection(smart_parking_clean);

OUTPUT:

ObsParking_IDCityUtil_ClassInstall_DateLast_Maint_DateSlots_TotalOccupancy_RateAvg_Search_TimeRevenueEfficiency_ScoreOccupied_SlotsUtilization_PercentParking_NameMonths_OperationalNext_MaintenanceFraud_Flag
1P001HyderabadHigh01JAN202401MAR202410085515000928585.0HYDERABAD_P0012623528No
2P002MumbaiHigh15FEB202401APR2024200110430000100200100.0MUMBAI_P0022523558No
3P003DelhiMedium01MAR202410MAR202415075608811375.3DELHI_P0032423537No
4P004BengaluruLow05JAN202401FEB2024120071800090..BENGALURU_P0042623497No
5P005ChennaiHigh01APR202401APR20248095312000957695.0CHENNAI_P0052323558No
6P006PuneLow01JAN202415JAN2024604588000702745.0PUNE_P0062623481No
7P007HyderabadHigh01JAN202401FEB2024901002200009990100.0HYDERABAD_P0072623497No
8P008MumbaiMedium01MAR202401MAR202411060917000856660.0MUMBAI_P0082423528No
9P009DelhiMedium01JAN202401APR2024140701021000879870.0DELHI_P0092623558No
10P010BengaluruHigh01FEB202401MAR2024130856220009311185.4BENGALURU_P0102523528No
11P011ChennaiLow01JAN202401JAN20249550125000604850.5CHENNAI_P0112623467No
12P012PuneLow01JAN202410JAN20247540154000553040.0PUNE_P0122623476No
13P013HyderabadHigh01JAN202401APR202420018035000098200100.0HYDERABAD_P0132623558No
14P014MumbaiLow01JAN202401JAN202410002002000.0MUMBAI_P0142623467No
15P015DelhiHigh01JAN202401MAR202416015044500096160100.0DELHI_P0152623528No

4. APPEND

data new_entry;

set smart_parking_clean(obs=3);

run;

proc print data=new_entry;

run;

OUTPUT:

ObsParking_IDCityUtil_ClassInstall_DateLast_Maint_DateSlots_TotalOccupancy_RateAvg_Search_TimeRevenueEfficiency_ScoreOccupied_SlotsUtilization_PercentParking_NameMonths_OperationalNext_Maintenance
1P001HyderabadHigh01JAN202401MAR202410085515000928585.0HYDERABAD_P0012623528
2P002MumbaiHigh15FEB202401APR2024200110430000100200100.0MUMBAI_P0022523558
3P003DelhiMedium01MAR202410MAR202415075608811375.3DELHI_P0032423537

proc append base=smart_parking_clean 

            data=new_entry force;

run;

proc print data=smart_parking_clean;

run;

OUTPUT:

ObsParking_IDCityUtil_ClassInstall_DateLast_Maint_DateSlots_TotalOccupancy_RateAvg_Search_TimeRevenueEfficiency_ScoreOccupied_SlotsUtilization_PercentParking_NameMonths_OperationalNext_Maintenance
1P001HyderabadHigh01JAN202401MAR202410085515000928585.0HYDERABAD_P0012623528
2P002MumbaiHigh15FEB202401APR2024200110430000100200100.0MUMBAI_P0022523558
3P003DelhiMedium01MAR202410MAR202415075608811375.3DELHI_P0032423537
4P004BengaluruLow05JAN202401FEB2024120071800090..BENGALURU_P0042623497
5P005ChennaiHigh01APR202401APR20248095312000957695.0CHENNAI_P0052323558
6P006PuneLow01JAN202415JAN2024604588000702745.0PUNE_P0062623481
7P007HyderabadHigh01JAN202401FEB2024901002200009990100.0HYDERABAD_P0072623497
8P008MumbaiMedium01MAR202401MAR202411060917000856660.0MUMBAI_P0082423528
9P009DelhiMedium01JAN202401APR2024140701021000879870.0DELHI_P0092623558
10P010BengaluruHigh01FEB202401MAR2024130856220009311185.4BENGALURU_P0102523528
11P011ChennaiLow01JAN202401JAN20249550125000604850.5CHENNAI_P0112623467
12P012PuneLow01JAN202410JAN20247540154000553040.0PUNE_P0122623476
13P013HyderabadHigh01JAN202401APR202420018035000098200100.0HYDERABAD_P0132623558
14P014MumbaiLow01JAN202401JAN202410002002000.0MUMBAI_P0142623467
15P015DelhiHigh01JAN202401MAR202416015044500096160100.0DELHI_P0152623528
16P001HyderabadHigh01JAN202401MAR202410085515000928585.0HYDERABAD_P0012623528
17P002MumbaiHigh15FEB202401APR2024200110430000100200100.0MUMBAI_P0022523558
18P003DelhiMedium01MAR202410MAR202415075608811375.3DELHI_P0032423537

5. MERGE

data city_target;

input City:$20. Target_Revenue;

datalines;

Hyderabad 20000

Mumbai 30000

Delhi 25000

;

run;

proc print data=city_target;

run;

OUTPUT:

ObsCityTarget_Revenue
1Hyderabad20000
2Mumbai30000
3Delhi25000

proc sort data=smart_parking_clean; by City; run;

proc print data=smart_parking_clean;

run;

OUTPUT:

ObsParking_IDCityUtil_ClassInstall_DateLast_Maint_DateSlots_TotalOccupancy_RateAvg_Search_TimeRevenueEfficiency_ScoreOccupied_SlotsUtilization_PercentParking_NameMonths_OperationalNext_Maintenance
1P004BengaluruLow05JAN202401FEB2024120071800090..BENGALURU_P0042623497
2P010BengaluruHigh01FEB202401MAR2024130856220009311185.4BENGALURU_P0102523528
3P005ChennaiHigh01APR202401APR20248095312000957695.0CHENNAI_P0052323558
4P011ChennaiLow01JAN202401JAN20249550125000604850.5CHENNAI_P0112623467
5P003DelhiMedium01MAR202410MAR202415075608811375.3DELHI_P0032423537
6P009DelhiMedium01JAN202401APR2024140701021000879870.0DELHI_P0092623558
7P015DelhiHigh01JAN202401MAR202416015044500096160100.0DELHI_P0152623528
8P003DelhiMedium01MAR202410MAR202415075608811375.3DELHI_P0032423537
9P001HyderabadHigh01JAN202401MAR202410085515000928585.0HYDERABAD_P0012623528
10P007HyderabadHigh01JAN202401FEB2024901002200009990100.0HYDERABAD_P0072623497
11P013HyderabadHigh01JAN202401APR202420018035000098200100.0HYDERABAD_P0132623558
12P001HyderabadHigh01JAN202401MAR202410085515000928585.0HYDERABAD_P0012623528
13P002MumbaiHigh15FEB202401APR2024200110430000100200100.0MUMBAI_P0022523558
14P008MumbaiMedium01MAR202401MAR202411060917000856660.0MUMBAI_P0082423528
15P014MumbaiLow01JAN202401JAN202410002002000.0MUMBAI_P0142623467
16P002MumbaiHigh15FEB202401APR2024200110430000100200100.0MUMBAI_P0022523558
17P006PuneLow01JAN202415JAN2024604588000702745.0PUNE_P0062623481
18P012PuneLow01JAN202410JAN20247540154000553040.0PUNE_P0122623476

proc sort data=city_target; by City; run;

proc print data=city_target;

run;

OUTPUT:

ObsCityTarget_Revenue
1Delhi25000
2Hyderabad20000
3Mumbai30000

data merged_data;

merge smart_parking_clean city_target;

by City;

run;

proc print data=merged_data;

run;

OUTPUT:

ObsParking_IDCityUtil_ClassInstall_DateLast_Maint_DateSlots_TotalOccupancy_RateAvg_Search_TimeRevenueEfficiency_ScoreOccupied_SlotsUtilization_PercentParking_NameMonths_OperationalNext_MaintenanceTarget_Revenue
1P004BengaluruLow05JAN202401FEB2024120071800090..BENGALURU_P0042623497.
2P010BengaluruHigh01FEB202401MAR2024130856220009311185.4BENGALURU_P0102523528.
3P005ChennaiHigh01APR202401APR20248095312000957695.0CHENNAI_P0052323558.
4P011ChennaiLow01JAN202401JAN20249550125000604850.5CHENNAI_P0112623467.
5P003DelhiMedium01MAR202410MAR202415075608811375.3DELHI_P003242353725000
6P009DelhiMedium01JAN202401APR2024140701021000879870.0DELHI_P009262355825000
7P015DelhiHigh01JAN202401MAR202416015044500096160100.0DELHI_P015262352825000
8P003DelhiMedium01MAR202410MAR202415075608811375.3DELHI_P003242353725000
9P001HyderabadHigh01JAN202401MAR202410085515000928585.0HYDERABAD_P001262352820000
10P007HyderabadHigh01JAN202401FEB2024901002200009990100.0HYDERABAD_P007262349720000
11P013HyderabadHigh01JAN202401APR202420018035000098200100.0HYDERABAD_P013262355820000
12P001HyderabadHigh01JAN202401MAR202410085515000928585.0HYDERABAD_P001262352820000
13P002MumbaiHigh15FEB202401APR2024200110430000100200100.0MUMBAI_P002252355830000
14P008MumbaiMedium01MAR202401MAR202411060917000856660.0MUMBAI_P008242352830000
15P014MumbaiLow01JAN202401JAN202410002002000.0MUMBAI_P014262346730000
16P002MumbaiHigh15FEB202401APR2024200110430000100200100.0MUMBAI_P002252355830000
17P006PuneLow01JAN202415JAN2024604588000702745.0PUNE_P0062623481.
18P012PuneLow01JAN202410JAN20247540154000553040.0PUNE_P0122623476.

6. TRANSPOSE

proc sort data=smart_parking_clean; by City; run;

proc print data=smart_parking_clean;

run;

OUTPUT:

ObsParking_IDCityUtil_ClassInstall_DateLast_Maint_DateSlots_TotalOccupancy_RateAvg_Search_TimeRevenueEfficiency_ScoreOccupied_SlotsUtilization_PercentParking_NameMonths_OperationalNext_Maintenance
1P004BengaluruLow05JAN202401FEB2024120071800090..BENGALURU_P0042623497
2P010BengaluruHigh01FEB202401MAR2024130856220009311185.4BENGALURU_P0102523528
3P005ChennaiHigh01APR202401APR20248095312000957695.0CHENNAI_P0052323558
4P011ChennaiLow01JAN202401JAN20249550125000604850.5CHENNAI_P0112623467
5P003DelhiMedium01MAR202410MAR202415075608811375.3DELHI_P0032423537
6P009DelhiMedium01JAN202401APR2024140701021000879870.0DELHI_P0092623558
7P015DelhiHigh01JAN202401MAR202416015044500096160100.0DELHI_P0152623528
8P003DelhiMedium01MAR202410MAR202415075608811375.3DELHI_P0032423537
9P001HyderabadHigh01JAN202401MAR202410085515000928585.0HYDERABAD_P0012623528
10P007HyderabadHigh01JAN202401FEB2024901002200009990100.0HYDERABAD_P0072623497
11P013HyderabadHigh01JAN202401APR202420018035000098200100.0HYDERABAD_P0132623558
12P001HyderabadHigh01JAN202401MAR202410085515000928585.0HYDERABAD_P0012623528
13P002MumbaiHigh15FEB202401APR2024200110430000100200100.0MUMBAI_P0022523558
14P008MumbaiMedium01MAR202401MAR202411060917000856660.0MUMBAI_P0082423528
15P014MumbaiLow01JAN202401JAN202410002002000.0MUMBAI_P0142623467
16P002MumbaiHigh15FEB202401APR2024200110430000100200100.0MUMBAI_P0022523558
17P006PuneLow01JAN202415JAN2024604588000702745.0PUNE_P0062623481
18P012PuneLow01JAN202410JAN20247540154000553040.0PUNE_P0122623476

proc transpose data=smart_parking_clean out=transposed;

by City;

var Revenue Utilization_Percent;

run;

proc print data=transposed;

run;

OUTPUT:

ObsCity_NAME_COL1COL2COL3COL4
1BengaluruRevenue18000.022000.0..
2BengaluruUtilization_Percent.85.4..
3ChennaiRevenue12000.05000.0..
4ChennaiUtilization_Percent95.050.5..
5DelhiRevenue0.021000.0450000.0
6DelhiUtilization_Percent75.370.010075.3
7HyderabadRevenue15000.020000.05000015000.0
8HyderabadUtilization_Percent85.0100.010085.0
9MumbaiRevenue30000.017000.0030000.0
10MumbaiUtilization_Percent100.060.00100.0
11PuneRevenue8000.04000.0..
12PuneUtilization_Percent45.040.0..

7. PROC DATASETS DELETE

proc datasets library=work;

delete smart_parking_raw;

quit;

LOG:

NOTE: Deleting WORK.SMART_PARKING_RAW (memtype=DATA).

8. PROC SQL ANALYSIS

proc sql;

create table revenue_summary as

select City,

       sum(Revenue) as Total_Revenue,

       mean(Utilization_Percent) as Avg_Util

from smart_parking_clean

group by City;

quit;

proc print data=revenue_summary;

run;

OUTPUT:

ObsCityTotal_RevenueAvg_Util
1Bengaluru4000085.40
2Chennai1700072.75
3Delhi6600080.15
4Hyderabad10000092.50
5Mumbai7700065.00
6Pune1200042.50

9. Sensor-Level Dataset

data sensor_data;

length Sensor_ID $6 Parking_ID $5 Status $10;

format Event_Time datetime20.;

input Sensor_ID $ Parking_ID $ Status $ Event_Time :datetime20.;

datalines;

S001 P001 Occupied 01JAN2024:10:15:00

S002 P001 Free 01JAN2024:10:16:00

S003 P002 Occupied 01JAN2024:10:17:00

S004 P003 Error 01JAN2024:10:18:00

S005 P004 Occupied 01JAN2024:10:19:00

;

run;

proc print data=sensor_data;

run;

OUTPUT:

ObsSensor_IDParking_IDStatusEvent_Time
1S001P001Occupied01JAN2024:10:15:00
2S002P001Free01JAN2024:10:16:00
3S003P002Occupied01JAN2024:10:17:00
4S004P003Error01JAN2024:10:18:00
5S005P004Occupied01JAN2024:10:19:00

·  Sensor malfunction

·  Ghost occupancy

·  Delayed updates

·  Duplicate events

10. Payment Transaction Dataset

data transactions;

length Trans_ID $6 Parking_ID $5 Payment_Mode $10;

format Payment_Date datetime20.;

input Trans_ID $ Parking_ID $ Amount Payment_Mode $ Payment_Date :datetime20.;

datalines;

T001 P001 200 UPI 01JAN2024:10:20:00

T002 P001 200 Card 01JAN2024:10:21:00

T003 P002 500 Cash 01JAN2024:10:22:00

T004 P003 1000 UPI 01JAN2024:10:23:00

T005 P014 0 Cash 01JAN2024:10:24:00

;

run;

proc print data=transactions;

run;

OUTPUT:

ObsTrans_IDParking_IDPayment_ModePayment_DateAmount
1T001P001UPI01JAN2024:10:20:00200
2T002P001Card01JAN2024:10:21:00200
3T003P002Cash01JAN2024:10:22:00500
4T004P003UPI01JAN2024:10:23:001000
5T005P014Cash01JAN2024:10:24:000

11. Revenue Reconciliation Logic

proc sql;

create table reconciliation as

select a.Parking_ID,

       count(b.Trans_ID) as Payment_Count,

       sum(b.Amount) as Collected_Revenue,

       a.Occupied_Slots,

       (a.Occupied_Slots * 200) as Expected_Revenue

from smart_parking_clean a

left join transactions b

on a.Parking_ID = b.Parking_ID

group by a.Parking_ID;

quit;

proc print data=reconciliation;

run;

OUTPUT:

ObsParking_IDPayment_CountCollected_RevenueOccupied_SlotsExpected_Revenue
1P00148008517000
2P00148008517000
3P00148008517000
4P00148008517000
5P0022100020040000
6P0022100020040000
7P0032200011322600
8P0032200011322600
9P0040...
10P0050.7615200
11P0060.275400
12P0070.9018000
13P0080.6613200
14P0090.9819600
15P0100.11122200
16P0110.489600
17P0120.306000
18P0130.20040000
19P0141000
20P0150.16032000

·  Occupied Slots vs Transactions

·  Revenue vs Expected Revenue

12. Fraud Indicator

data reconciliation_flag;

set reconciliation;

if Collected_Revenue < Expected_Revenue then Revenue_Leak="Yes";

else Revenue_Leak="No";

run;

proc print data=reconciliation_flag;

run;

OUTPUT:

ObsParking_IDPayment_CountCollected_RevenueOccupied_SlotsExpected_RevenueRevenue_Leak
1P00148008517000Yes
2P00148008517000Yes
3P00148008517000Yes
4P00148008517000Yes
5P0022100020040000Yes
6P0022100020040000Yes
7P0032200011322600Yes
8P0032200011322600Yes
9P0040...No
10P0050.7615200Yes
11P0060.275400Yes
12P0070.9018000Yes
13P0080.6613200Yes
14P0090.9819600Yes
15P0100.11122200Yes
16P0110.489600Yes
17P0120.306000Yes
18P0130.20040000Yes
19P0141000No
20P0150.16032000Yes

·  Use WHERE instead of IF

·  Avoid unnecessary SORT

·  Use HASH joins for speed

·  Use KEEP and DROP

13. Advanced Fraud Scoring Model

data fraud_score;

set reconciliation_flag;

Score = 0;

if Revenue_Leak="Yes" then Score+40;

if Payment_Count < Occupied_Slots then Score+30;

if Expected_Revenue > 40000 and Collected_Revenue < 20000 then Score+20;

if Occupied_Slots = Slots_Total then Score+10;

if Score >=60 then Risk_Level="High";

else if Score>=30 then Risk_Level="Medium";

else Risk_Level="Low";

run;

proc print data=fraud_score;

run;

OUTPUT:

ObsParking_IDPayment_CountCollected_RevenueOccupied_SlotsExpected_RevenueRevenue_LeakScoreSlots_TotalRisk_Level
1P00148008517000Yes70.High
2P00148008517000Yes70.High
3P00148008517000Yes70.High
4P00148008517000Yes70.High
5P0022100020040000Yes70.High
6P0022100020040000Yes70.High
7P0032200011322600Yes70.High
8P0032200011322600Yes70.High
9P0040...No10.Low
10P0050.7615200Yes70.High
11P0060.275400Yes70.High
12P0070.9018000Yes70.High
13P0080.6613200Yes70.High
14P0090.9819600Yes70.High
15P0100.11122200Yes70.High
16P0110.489600Yes70.High
17P0120.306000Yes70.High
18P0130.20040000Yes70.High
19P0141000No0.Low
20P0150.16032000Yes70.High

14. Efficiency KPI Framework

data kpi_engine;

set smart_parking_clean;

Revenue_Per_Slot = Revenue / Slots_Total;

Search_Time_Index = Avg_Search_Time / 10;

Utilization_Index = Utilization_Percent / 100;

Composite_Efficiency = round((Revenue_Per_Slot*0.4 + 

                               Utilization_Index*0.4 - 

                               Search_Time_Index*0.2)*100,0.1);

run;

proc print data=kpi_engine;

run;

OUTPUT:

ObsParking_IDCityUtil_ClassInstall_DateLast_Maint_DateSlots_TotalOccupancy_RateAvg_Search_TimeRevenueEfficiency_ScoreOccupied_SlotsUtilization_PercentParking_NameMonths_OperationalNext_MaintenanceRevenue_Per_SlotSearch_Time_IndexUtilization_IndexComposite_Efficiency
1P004BengaluruLow05JAN202401FEB2024120071800090..BENGALURU_P0042623497150.0000.7..
2P010BengaluruHigh01FEB202401MAR2024130856220009311185.4BENGALURU_P0102523528169.2310.60.8546791.4
3P005ChennaiHigh01APR202401APR20248095312000957695.0CHENNAI_P0052323558150.0000.30.9506032.0
4P011ChennaiLow01JAN202401JAN20249550125000604850.5CHENNAI_P011262346752.6321.20.5052101.5
5P003DelhiMedium01MAR202410MAR202415075608811375.3DELHI_P00324235370.0000.60.75318.1
6P009DelhiMedium01JAN202401APR2024140701021000879870.0DELHI_P0092623558150.0001.00.7006008.0
7P015DelhiHigh01JAN202401MAR202416015044500096160100.0DELHI_P0152623528281.2500.41.00011282.0
8P003DelhiMedium01MAR202410MAR202415075608811375.3DELHI_P00324235370.0000.60.75318.1
9P001HyderabadHigh01JAN202401MAR202410085515000928585.0HYDERABAD_P0012623528150.0000.50.8506024.0
10P007HyderabadHigh01JAN202401FEB2024901002200009990100.0HYDERABAD_P0072623497222.2220.21.0008924.9
11P013HyderabadHigh01JAN202401APR202420018035000098200100.0HYDERABAD_P0132623558250.0000.31.00010034.0
12P001HyderabadHigh01JAN202401MAR202410085515000928585.0HYDERABAD_P0012623528150.0000.50.8506024.0
13P002MumbaiHigh15FEB202401APR2024200110430000100200100.0MUMBAI_P0022523558150.0000.41.0006032.0
14P008MumbaiMedium01MAR202401MAR202411060917000856660.0MUMBAI_P0082423528154.5450.90.6006187.8
15P014MumbaiLow01JAN202401JAN202410002002000.0MUMBAI_P01426234670.0002.00.000-40.0
16P002MumbaiHigh15FEB202401APR2024200110430000100200100.0MUMBAI_P0022523558150.0000.41.0006032.0
17P006PuneLow01JAN202415JAN2024604588000702745.0PUNE_P0062623481133.3330.80.4505335.3
18P012PuneLow01JAN202410JAN20247540154000553040.0PUNE_P012262347653.3331.50.4002119.3

15. Real-Time Utilization Engine

proc sql;

create table live_utilization as

select Parking_ID,

       count(case when Status="Occupied" then 1 end) as Live_Occupied,

       calculated Live_Occupied / 100 * 100 as Live_Utilization

from sensor_data

group by Parking_ID;

quit;

proc print data=live_utilization;

run;

OUTPUT:

ObsParking_IDLive_OccupiedLive_Utilization
1P00111
2P00211
3P00300
4P00411

16. Predictive Maintenance Engine

data maintenance_risk;

set smart_parking_clean;

Days_Since_Maint = intck('day',Last_Maint_Date,today());

if Days_Since_Maint > 90 then Maint_Risk="High";

else if Days_Since_Maint >60 then Maint_Risk="Medium";

else Maint_Risk="Low";

run;

proc print data=maintenance_risk;

run;

OUTPUT:

ObsParking_IDCityUtil_ClassInstall_DateLast_Maint_DateSlots_TotalOccupancy_RateAvg_Search_TimeRevenueEfficiency_ScoreOccupied_SlotsUtilization_PercentParking_NameMonths_OperationalNext_MaintenanceDays_Since_MaintMaint_Risk
1P004BengaluruLow05JAN202401FEB2024120071800090..BENGALURU_P0042623497761High
2P010BengaluruHigh01FEB202401MAR2024130856220009311185.4BENGALURU_P0102523528732High
3P005ChennaiHigh01APR202401APR20248095312000957695.0CHENNAI_P0052323558701High
4P011ChennaiLow01JAN202401JAN20249550125000604850.5CHENNAI_P0112623467792High
5P003DelhiMedium01MAR202410MAR202415075608811375.3DELHI_P0032423537723High
6P009DelhiMedium01JAN202401APR2024140701021000879870.0DELHI_P0092623558701High
7P015DelhiHigh01JAN202401MAR202416015044500096160100.0DELHI_P0152623528732High
8P003DelhiMedium01MAR202410MAR202415075608811375.3DELHI_P0032423537723High
9P001HyderabadHigh01JAN202401MAR202410085515000928585.0HYDERABAD_P0012623528732High
10P007HyderabadHigh01JAN202401FEB2024901002200009990100.0HYDERABAD_P0072623497761High
11P013HyderabadHigh01JAN202401APR202420018035000098200100.0HYDERABAD_P0132623558701High
12P001HyderabadHigh01JAN202401MAR202410085515000928585.0HYDERABAD_P0012623528732High
13P002MumbaiHigh15FEB202401APR2024200110430000100200100.0MUMBAI_P0022523558701High
14P008MumbaiMedium01MAR202401MAR202411060917000856660.0MUMBAI_P0082423528732High
15P014MumbaiLow01JAN202401JAN202410002002000.0MUMBAI_P0142623467792High
16P002MumbaiHigh15FEB202401APR2024200110430000100200100.0MUMBAI_P0022523558701High
17P006PuneLow01JAN202415JAN2024604588000702745.0PUNE_P0062623481778High
18P012PuneLow01JAN202410JAN20247540154000553040.0PUNE_P0122623476783High

17. Data Quality Validation Framework

%macro dq_check(ds);

proc sql noprint;

select count(*) into: missing_count

from &ds

where missing(Occupancy_Rate);

quit;

%put Missing Count = &missing_count;

%mend;


%dq_check(smart_parking_clean);

LOG:

Missing Count = 0

18. Audit Trail System

data audit_log;

length Process $30 Status $10;

format Timestamp datetime20.;

Process="Fraud Scoring";

Status="Completed";

Timestamp=datetime();

run;

proc print data=audit_log;

run;

OUTPUT:

ObsProcessStatusTimestamp
1Fraud ScoringCompleted03MAR2026:16:59:22

19. Performance Optimization Techniques

proc datasets library=work;

modify smart_parking_clean;

index create Parking_ID;

quit;

LOG:

NOTE: MODIFY was successful for WORK.SMART_PARKING_CLEAN.DATA.

🔢 Numeric Functions

·  ROUND

·  COALESCE

·  ABS

·  INTCK

·  INTNX

🔤 Character Functions

·  STRIP

·  TRIM

·  CAT

·  CATX

·  UPCASE

·  LOWCASE

·  PROPCASE

20 KEY POINTS ABOUT THIS PROJECT

·  Created a realistic Smart Parking dataset with more than 15 observations.

·  Introduced intentional errors such as negative revenue and occupancy > capacity.

·  Detected data inconsistencies using conditional logic.

·  Cleaned city names using STRIP and PROPCASE functions.

·  Calculated Occupied_Slots using ROUND numeric function.

·  Used COALESCE to handle missing values.

·  Derived Utilization_Percent and classified into High, Medium, Low.

·  Applied INTCK to compute operational months.

·  Used INTNX to schedule next maintenance.

·  Designed rule-based fraud detection macro.

·  Built revenue reconciliation between occupancy and transactions.

·  Developed a fraud scoring system instead of simple Yes/No flags.

·  Created sensor-level dataset for real-time utilization monitoring.

·  Used PROC SQL for aggregation and reconciliation.

·  Applied MERGE to integrate target revenue data.

·  Used APPEND to simulate incremental data loading.

·  Applied TRANSPOSE to reshape KPI reporting.

·  Implemented data quality macro for validation checks.

·  Created audit log dataset to track processing.

·  Optimized performance using indexing and dataset management.

SUMMARY

In this complete Smart Parking Analytics Project, we began by designing a foundational dataset containing parking-level metrics such as total slots, occupancy rate, revenue, search time, and efficiency score. We intentionally inserted data errors to replicate real-world data inconsistencies.

We then applied systematic debugging techniques using SAS DATA step logic to identify and correct these issues. Standardization techniques were applied using character functions like PROPCASE and STRIP. Numeric validations ensured revenue and efficiency scores remained within acceptable thresholds.Date functions such as MDY, INTCK, and INTNX were used to calculate operational timelines and schedule maintenance events. This added a time-based analytical layer.We developed a rule-based fraud detection macro to automatically flag suspicious records. This evolved into a more advanced fraud scoring model that assigned weighted risk levels.

The project was extended further by adding sensor-level event logs and payment transaction datasets. Revenue reconciliation logic was implemented to compare expected revenue against collected revenue. This helped detect potential financial leakage.A predictive maintenance engine calculated risk levels based on elapsed time since last service. Data quality checks were automated using macros, and audit logs were created to simulate compliance frameworks.Performance optimization techniques such as indexing and efficient SQL aggregation were incorporated to support scalability.The project demonstrates full-cycle analytics: data ingestion, cleaning, transformation, validation, fraud detection, KPI generation, and enterprise optimization.

CONCLUSION

This project proves that we can design, debug, detect fraud, and optimize a Smart Parking ecosystem using advanced SAS programming techniques.

The base project demonstrated strong fundamentals:

·       Data cleaning

·       Validation

·       Utilization analytics

·       Fraud detection

·       Enterprise-grade architecture

·       Revenue reconciliation engine

·       Predictive maintenance framework

·       Sensor-based real-time monitoring

·       Data governance structure

·       Performance optimization strategy

This type of project reflects real production-level analytical thinking. It showcases not only programming skills but also:

·       Business understanding

·       Risk identification

·       Operational efficiency modeling

·       Strategic system design

·       Machine learning-based anomaly detection

·       Time-series revenue forecasting

·       Geo-spatial parking demand prediction

·       Cloud-based real-time analytics platform


SAS INTERVIEW QUESTIONS

·  How do you handle missing values?

·  What is reconciliation?

·  What is log checking?

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

About the Author:

SAS Learning Hub is a data analytics and SAS programming platform focused on clinical, financial, and real-world data analysis. The content is created by professionals with academic training in Pharmaceutics and hands-on experience in Base SAS, PROC SQL, Macros, SDTM, and ADaM, providing practical and industry-relevant SAS learning resources.


Disclaimer:

The datasets and analysis in this article are created for educational and demonstration purposes only. They do not represent PARKING SYSTEM data.


Our Mission:

This blog provides industry-focused SAS programming tutorials and analytics projects covering finance, healthcare, and technology.


This project is suitable for:

·  Students learning SAS

·  Data analysts building portfolios

·  Professionals preparing for SAS interviews

·  Bloggers writing about analytics 

·  Clinical SAS Programmer

·  Research Data Analyst

·  Regulatory Data Validator

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Follow Us On : 


 
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

--->Follow our blog for more SAS-based analytics projects and industry data models.

---> Support Us By Following Our Blog..

To deepen your understanding of SAS analytics, please refer to our other data science and industry-focused projects listed below:

1.How Do We Build a Complete River Trade and Pollution Monitoring System in SAS Using MERGE, APPEND, TRANSPOSE, and Macros?


--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

About Us | Contact Privacy Policy


Comments

Popular posts from this blog

412.Can We Build And Clean A University Course Analytics & Fraud Detection System In Sas Using Only Macros While Intentionally Creating And Fixing Errors?

416.Can We Design, Debug, Detect Fraud, and Build an ADaM-Ready Autonomous Drone Flight Analytics System Using Advanced SAS Programming Techniques?