391. Are Your Sensors Lying? Fraud Detection in Smart Home Systems Using SAS

Are Your Sensors Lying? Fraud Detection in Smart Home Systems Using SAS

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

HERE IN THIS PROJECT WE USED THESE SAS STATEMENTS —
DATA STEP | PROC SQL |  PROC PRINT | PROC SGPLOT | MACROS | PROC CORR | PROC MEANS | PROC FREQ | PROC UNIVARIATE | APPEND | SET | PROC SORT | MERGE | PROC DATASETS DELETE | DATA FUNCTIONS

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

INTRODUCTION

In today’s digital era, Smart Home Systems have become an integral part of modern living. Smart homes rely on a network of interconnected sensors to monitor, control, and automate various household activities such as lighting, temperature, security, energy consumption, and safety. These sensors continuously generate large volumes of data, which must be analyzed effectively to ensure system reliability, efficiency, and security.

This project, Smart Home Sensors Analytics using SAS, is designed to simulate a real-world IoT (Internet of Things) environment where multiple smart sensors are installed across different rooms of a house. Each sensor records operational metrics such as power consumption, data transmission frequency, error rate, latency, and reliability score. By analyzing this data using SAS, we aim to derive meaningful insights that can help businesses optimize system performance, detect faulty or fraudulent sensors, and plan maintenance activities.

The primary objective of this project is to demonstrate how SAS can be used as a powerful analytics platform for IoT data. The project covers the complete data lifecycle including data creation, data transformation, statistical analysis, visualization, automation using macros, and business interpretation. This makes it a comprehensive case study for students, data analysts, and SAS programmers.

TABLE OF CONTENTS

  1. Introduction
  2. Business Context
  3. Problem Statement
  4. Project Objectives
  5. Data Description
  6. Data Creation using SAS
  7. Data Transformation and Cleaning
  8. Date and Time Analysis
  9. Utilization Classification using Macros
  10. Fraud Detection Logic
  11. SQL-Based Aggregation
  12. Descriptive Statistical Analysis
  13. Univariate Analysis
  14. Frequency Analysis
  15. Correlation Analysis
  16. Graphical Visualization
  17. Data Transposition
  18. Dataset Merging and Appending
  19. Character and Numeric Functions
  20. Dataset Maintenance and Cleanup
  21. Key Business Insights
  22. Practical Applications
  23. Interview Relevance
  24. Conclusion

1. BUSINESS CONTEXT

Smart home technology is widely used by:

  • Real estate companies
  • IoT device manufacturers
  • Home automation service providers
  • Energy management firms
  • Security and surveillance companies

These organizations need continuous monitoring of sensor behavior to ensure:

  • High reliability
  • Low power consumption
  • Minimal errors
  • Fast response time
  • Strong security

Poor sensor performance can lead to:

  • Increased energy costs
  • False alarms
  • System downtime
  • Customer dissatisfaction
  • Security risks

PROBLEM STATEMENT

The key challenges addressed in this project are:

  1. Identifying sensors with high power consumption
  2. Detecting sensors with high error rates
  3. Monitoring latency issues
  4. Measuring overall reliability
  5. Classifying sensors based on utilization
  6. Detecting suspicious or fraudulent sensor behavior
  7. Performing statistical and correlation analysis
  8. Visualizing performance patterns
  9. Managing and cleaning raw sensor data

PROJECT OBJECTIVES

The main objectives of this Smart Home Sensor project are:

  • To create a realistic sensor dataset
  • To apply SAS data step programming
  • To use SQL for business aggregation
  • To perform descriptive and inferential statistics
  • To implement macros for automation
  • To apply date functions for lifecycle analysis
  • To visualize data using graphical procedures
  • To demonstrate data cleaning techniques
  • To build a complete end-to-end analytics pipeline

DATA DESCRIPTION

The dataset consists of the following key variables:

Variable Name

Description

Sensor_ID

Unique identifier for each sensor

Room_Type

Location of sensor

Data_Frequency

Number of data transmissions per minute

Power_Consumption

Energy usage

Error_Rate

Percentage of faulty readings

Latency

Delay in milliseconds

Reliability_Score

Performance rating

Install_Date

Date of installation

Utilization

High/Medium/Low classification

Fraud_Flag

Indicates suspicious behavior

Days_Active

Number of days since installation

Next_Service

Next maintenance date

2. DATASET CREATION

data smart_sensors;

    input Sensor_ID $ Room_Type:$12. Data_Frequency Power_Consumption Error_Rate Latency

          Reliability_Score Install_Date :date9.;

    Power_Pct = Power_Consumption / 100;

    Error_Pct = Error_Rate / 100;

    format Install_Date date9.;

datalines;

S001 LivingRoom 60 35 2 120 95 01JAN2024

S002 Kitchen 30 55 8 200 70 05JAN2024

S003 Bedroom 15 20 1 80 98 10JAN2024

S004 Bathroom 45 40 5 160 85 15JAN2024

S005 Garage 20 70 15 300 60 20JAN2024

S006 Hall 60 25 2 110 96 25JAN2024

S007 Balcony 10 15 1 70 99 01FEB2024

S008 Office 50 60 10 220 75 05FEB2024

S009 Dining 30 45 6 180 88 10FEB2024

S010 KidsRoom 20 30 3 100 94 15FEB2024

S011 StoreRoom 10 10 0.5 50 100 20FEB2024

S012 Kitchen 25 65 12 240 72 25FEB2024

S013 LivingRoom 55 38 4 150 90 01MAR2024

S014 Bedroom 15 22 1 90 97 05MAR2024

S015 Garage 30 75 18 350 55 10MAR2024

S016 Office 60 58 9 210 78 15MAR2024

;

run;

proc print data=smart_sensors;

run;

OUTPUT:

ObsSensor_IDRoom_TypeData_FrequencyPower_ConsumptionError_RateLatencyReliability_ScoreInstall_DatePower_PctError_Pct
1S001LivingRoom60352.01209501JAN20240.350.020
2S002Kitchen30558.02007005JAN20240.550.080
3S003Bedroom15201.0809810JAN20240.200.010
4S004Bathroom45405.01608515JAN20240.400.050
5S005Garage207015.03006020JAN20240.700.150
6S006Hall60252.01109625JAN20240.250.020
7S007Balcony10151.0709901FEB20240.150.010
8S008Office506010.02207505FEB20240.600.100
9S009Dining30456.01808810FEB20240.450.060
10S010KidsRoom20303.01009415FEB20240.300.030
11S011StoreRoom10100.55010020FEB20240.100.005
12S012Kitchen256512.02407225FEB20240.650.120
13S013LivingRoom55384.01509001MAR20240.380.040
14S014Bedroom15221.0909705MAR20240.220.010
15S015Garage307518.03505510MAR20240.750.180
16S016Office60589.02107815MAR20240.580.090

3. MACRO – UTILIZATION CLASSIFICATION

%macro utilization;

data smart_sensors;

    set smart_sensors;

    length Utilization $8.;

    if Power_Consumption > 60 then Utilization = "High";

    else if 30 < Power_Consumption < 60 then Utilization = "Medium";

    else Utilization = "Low";

run;

proc print data=smart_sensors;

run;

%mend;


%utilization;

OUTPUT:

ObsSensor_IDRoom_TypeData_FrequencyPower_ConsumptionError_RateLatencyReliability_ScoreInstall_DatePower_PctError_PctUtilization
1S001LivingRoom60352.01209501JAN20240.350.020Medium
2S002Kitchen30558.02007005JAN20240.550.080Medium
3S003Bedroom15201.0809810JAN20240.200.010Low
4S004Bathroom45405.01608515JAN20240.400.050Medium
5S005Garage207015.03006020JAN20240.700.150High
6S006Hall60252.01109625JAN20240.250.020Low
7S007Balcony10151.0709901FEB20240.150.010Low
8S008Office506010.02207505FEB20240.600.100Low
9S009Dining30456.01808810FEB20240.450.060Medium
10S010KidsRoom20303.01009415FEB20240.300.030Low
11S011StoreRoom10100.55010020FEB20240.100.005Low
12S012Kitchen256512.02407225FEB20240.650.120High
13S013LivingRoom55384.01509001MAR20240.380.040Medium
14S014Bedroom15221.0909705MAR20240.220.010Low
15S015Garage307518.03505510MAR20240.750.180High
16S016Office60589.02107815MAR20240.580.090Medium

4. DATE FUNCTIONS

data smart_sensors;

    set smart_sensors;

    Today = today();

    Days_Active = intck('day', Install_Date, Today);

    Next_Service = intnx('month', Install_Date, 6);

run;

proc print data=smart_sensors;

run;

OUTPUT:

ObsSensor_IDRoom_TypeData_FrequencyPower_ConsumptionError_RateLatencyReliability_ScoreInstall_DatePower_PctError_PctUtilizationTodayDays_ActiveNext_Service
1S001LivingRoom60352.01209501JAN20240.350.020Medium2414176523558
2S002Kitchen30558.02007005JAN20240.550.080Medium2414176123558
3S003Bedroom15201.0809810JAN20240.200.010Low2414175623558
4S004Bathroom45405.01608515JAN20240.400.050Medium2414175123558
5S005Garage207015.03006020JAN20240.700.150High2414174623558
6S006Hall60252.01109625JAN20240.250.020Low2414174123558
7S007Balcony10151.0709901FEB20240.150.010Low2414173423589
8S008Office506010.02207505FEB20240.600.100Low2414173023589
9S009Dining30456.01808810FEB20240.450.060Medium2414172523589
10S010KidsRoom20303.01009415FEB20240.300.030Low2414172023589
11S011StoreRoom10100.55010020FEB20240.100.005Low2414171523589
12S012Kitchen256512.02407225FEB20240.650.120High2414171023589
13S013LivingRoom55384.01509001MAR20240.380.040Medium2414170523620
14S014Bedroom15221.0909705MAR20240.220.010Low2414170123620
15S015Garage307518.03505510MAR20240.750.180High2414169623620
16S016Office60589.02107815MAR20240.580.090Medium2414169123620

5. FRAUD DETECTION MACRO

%macro fraud_check;

data fraud_sensors;

    set smart_sensors;

    length Fraud_Flag $3.;

    if Error_Rate > 10 or Latency > 250 then Fraud_Flag = "YES";

    else Fraud_Flag = "NO";

run;

proc print data=fraud_sensors;

run;

%mend;


%fraud_check;

OUTPUT:

ObsSensor_IDRoom_TypeData_FrequencyPower_ConsumptionError_RateLatencyReliability_ScoreInstall_DatePower_PctError_PctUtilizationTodayDays_ActiveNext_ServiceFraud_Flag
1S001LivingRoom60352.01209501JAN20240.350.020Medium2414176523558NO
2S002Kitchen30558.02007005JAN20240.550.080Medium2414176123558NO
3S003Bedroom15201.0809810JAN20240.200.010Low2414175623558NO
4S004Bathroom45405.01608515JAN20240.400.050Medium2414175123558NO
5S005Garage207015.03006020JAN20240.700.150High2414174623558YES
6S006Hall60252.01109625JAN20240.250.020Low2414174123558NO
7S007Balcony10151.0709901FEB20240.150.010Low2414173423589NO
8S008Office506010.02207505FEB20240.600.100Low2414173023589NO
9S009Dining30456.01808810FEB20240.450.060Medium2414172523589NO
10S010KidsRoom20303.01009415FEB20240.300.030Low2414172023589NO
11S011StoreRoom10100.55010020FEB20240.100.005Low2414171523589NO
12S012Kitchen256512.02407225FEB20240.650.120High2414171023589YES
13S013LivingRoom55384.01509001MAR20240.380.040Medium2414170523620NO
14S014Bedroom15221.0909705MAR20240.220.010Low2414170123620NO
15S015Garage307518.03505510MAR20240.750.180High2414169623620YES
16S016Office60589.02107815MAR20240.580.090Medium2414169123620NO

6. PROC SQL ANALYTICS

proc sql;

create table room_summary as

select Room_Type,

       avg(Power_Consumption) as Avg_Power,

       avg(Error_Rate) as Avg_Error,

       avg(Reliability_Score) as Avg_Reliability

from smart_sensors

group by Room_Type;

quit;

proc print data=room_summary;

run;

OUTPUT:

ObsRoom_TypeAvg_PowerAvg_ErrorAvg_Reliability
1Balcony15.01.099.0
2Bathroom40.05.085.0
3Bedroom21.01.097.5
4Dining45.06.088.0
5Garage72.516.557.5
6Hall25.02.096.0
7KidsRoom30.03.094.0
8Kitchen60.010.071.0
9LivingRoom36.53.092.5
10Office59.09.576.5
11StoreRoom10.00.5100.0

7. PROC MEANS

proc means data=smart_sensors mean min max std;

var Power_Consumption Error_Rate Latency Reliability_Score;

run;

OUTPUT:

The MEANS Procedure

VariableMeanMinimumMaximumStd Dev
Power_Consumption
Error_Rate
Latency
Reliability_Score
41.4375000
6.0937500
164.3750000
84.5000000
10.0000000
0.5000000
50.0000000
55.0000000
75.0000000
18.0000000
350.0000000
100.0000000
20.4840385
5.4228490
85.3204743
14.4545264

8. PROC UNIVARIATE

proc univariate data=smart_sensors;

    var Power_Consumption Latency;

    histogram Power_Consumption Latency / normal kernel midpoints=10 to 80 by 10 

                                          cfill=gray vscale=count;

    inset mean median std min max n / position=ne;

    probplot Power_Consumption Latency / normal(mu=est sigma=est);

run;

OUTPUT:

The UNIVARIATE Procedure

Variable: Power_Consumption

Moments
N16Sum Weights16
Mean41.4375Sum Observations663
Std Deviation20.4840385Variance419.595833
Skewness0.130103Kurtosis-1.2290794
Uncorrected SS33767Corrected SS6293.9375
Coeff Variation49.4335771Std Error Mean5.12100963
Basic Statistical Measures
LocationVariability
Mean41.43750Std Deviation20.48404
Median39.00000Variance419.59583
Mode.Range65.00000
  Interquartile Range35.50000
Tests for Location: Mu0=0
TestStatisticp Value
Student's tt8.091666Pr > |t|<.0001
SignM8Pr >= |M|<.0001
Signed RankS68Pr >= |S|<.0001
Quantiles (Definition 5)
LevelQuantile
100% Max75.0
99%75.0
95%75.0
90%70.0
75% Q359.0
50% Median39.0
25% Q123.5
10%15.0
5%10.0
1%10.0
0% Min10.0
Extreme Observations
LowestHighest
ValueObsValueObs
10115816
157608
2036512
2214705
2567515


The UNIVARIATE Procedure

Histogram for Power_Consumption


The UNIVARIATE Procedure

Fitted Normal Distribution for Power_Consumption

Parameters for Normal Distribution
ParameterSymbolEstimate
MeanMu41.4375
Std DevSigma20.48404
Goodness-of-Fit Tests for Normal Distribution
TestStatisticp Value
Kolmogorov-SmirnovD0.12104672Pr > D>0.150
Cramer-von MisesW-Sq0.03880802Pr > W-Sq>0.250
Anderson-DarlingA-Sq0.25231907Pr > A-Sq>0.250
Quantiles for Normal Distribution
PercentQuantile
ObservedEstimated
1.010.00000-6.21550
5.010.000007.74425
10.015.0000015.18615
25.023.5000027.62123
50.039.0000041.43750
75.059.0000055.25377
90.070.0000067.68885
95.075.0000075.13075
99.075.0000089.09050

The UNIVARIATE Procedure

Probability Plot for Power_Consumption

The UNIVARIATE Procedure

Variable: Latency

Moments
N16Sum Weights16
Mean164.375Sum Observations2630
Std Deviation85.3204743Variance7279.58333
Skewness0.70811576Kurtosis-0.0698201
Uncorrected SS541500Corrected SS109193.75
Coeff Variation51.905992Std Error Mean21.3301186
Basic Statistical Measures
LocationVariability
Mean164.3750Std Deviation85.32047
Median155.0000Variance7280
Mode.Range300.00000
  Interquartile Range120.00000
Tests for Location: Mu0=0
TestStatisticp Value
Student's tt7.706239Pr > |t|<.0001
SignM8Pr >= |M|<.0001
Signed RankS68Pr >= |S|<.0001
Quantiles (Definition 5)
LevelQuantile
100% Max350
99%350
95%350
90%300
75% Q3215
50% Median155
25% Q195
10%70
5%50
1%50
0% Min50
Extreme Observations
LowestHighest
ValueObsValueObs
501121016
7072208
80324012
90143005
1001035015

The UNIVARIATE Procedure

Histogram for Latency


The UNIVARIATE Procedure

Fitted Normal Distribution for Latency

Parameters for Normal Distribution
ParameterSymbolEstimate
MeanMu164.375
Std DevSigma85.32047
Goodness-of-Fit Tests for Normal Distribution
TestStatisticp Value
Kolmogorov-SmirnovD0.13600233Pr > D>0.150
Cramer-von MisesW-Sq0.04068360Pr > W-Sq>0.250
Anderson-DarlingA-Sq0.29784435Pr > A-Sq>0.250
Quantiles for Normal Distribution
PercentQuantile
ObservedEstimated
1.050.0000-34.1101
5.050.000024.0353
10.070.000055.0324
25.095.0000106.8272
50.0155.0000164.3750
75.0215.0000221.9228
90.0300.0000273.7176
95.0350.0000304.7147
99.0350.0000362.8601

The UNIVARIATE Procedure

Probability Plot for Latency

9. PROC FREQ

proc freq data=smart_sensors;

tables Room_Type*Utilization;

run;

OUTPUT:

The FREQ Procedure

Frequency
Percent
Row Pct
Col Pct
Table of Room_Type by Utilization
Room_TypeUtilization
HighLowMediumTotal
Balcony
0
0.00
0.00
0.00
1
6.25
100.00
14.29
0
0.00
0.00
0.00
1
6.25
 
 
Bathroom
0
0.00
0.00
0.00
0
0.00
0.00
0.00
1
6.25
100.00
16.67
1
6.25
 
 
Bedroom
0
0.00
0.00
0.00
2
12.50
100.00
28.57
0
0.00
0.00
0.00
2
12.50
 
 
Dining
0
0.00
0.00
0.00
0
0.00
0.00
0.00
1
6.25
100.00
16.67
1
6.25
 
 
Garage
2
12.50
100.00
66.67
0
0.00
0.00
0.00
0
0.00
0.00
0.00
2
12.50
 
 
Hall
0
0.00
0.00
0.00
1
6.25
100.00
14.29
0
0.00
0.00
0.00
1
6.25
 
 
KidsRoom
0
0.00
0.00
0.00
1
6.25
100.00
14.29
0
0.00
0.00
0.00
1
6.25
 
 
Kitchen
1
6.25
50.00
33.33
0
0.00
0.00
0.00
1
6.25
50.00
16.67
2
12.50
 
 
LivingRoom
0
0.00
0.00
0.00
0
0.00
0.00
0.00
2
12.50
100.00
33.33
2
12.50
 
 
Office
0
0.00
0.00
0.00
1
6.25
50.00
14.29
1
6.25
50.00
16.67
2
12.50
 
 
StoreRoom
0
0.00
0.00
0.00
1
6.25
100.00
14.29
0
0.00
0.00
0.00
1
6.25
 
 
Total
3
18.75
7
43.75
6
37.50
16
100.00

10. PROC CORR

proc corr data=smart_sensors;

var Power_Consumption Error_Rate Latency Reliability_Score;

run;

OUTPUT:

The CORR Procedure

4 Variables:Power_Consumption Error_Rate Latency Reliability_Score
Simple Statistics
VariableNMeanStd DevSumMinimumMaximum
Power_Consumption1641.4375020.48404663.0000010.0000075.00000
Error_Rate166.093755.4228597.500000.5000018.00000
Latency16164.3750085.32047263050.00000350.00000
Reliability_Score1684.5000014.45453135255.00000100.00000
Pearson Correlation Coefficients, N = 16
Prob > |r| under H0: Rho=0
 Power_ConsumptionError_RateLatencyReliability_Score
Power_Consumption
1.00000
 
0.95776
<.0001
0.97382
<.0001
-0.95479
<.0001
Error_Rate
0.95776
<.0001
1.00000
 
0.98678
<.0001
-0.97957
<.0001
Latency
0.97382
<.0001
0.98678
<.0001
1.00000
 
-0.97438
<.0001
Reliability_Score
-0.95479
<.0001
-0.97957
<.0001
-0.97438
<.0001
1.00000
 

11. PROC SGPLOT

proc sgplot data=smart_sensors;

scatter x=Power_Consumption y=Reliability_Score;

run;

OUTPUT:

The SGPlot Procedure

12. PROC TRANSPOSE

proc transpose data=smart_sensors out=transposed;

by Sensor_ID NotSorted;

var Power_Consumption Error_Rate Latency;

run;

proc print data=transposed;

run;

OUTPUT:

ObsSensor_ID_NAME_COL1
1S001Power_Consumption35.0
2S001Error_Rate2.0
3S001Latency120.0
4S002Power_Consumption55.0
5S002Error_Rate8.0
6S002Latency200.0
7S003Power_Consumption20.0
8S003Error_Rate1.0
9S003Latency80.0
10S004Power_Consumption40.0
11S004Error_Rate5.0
12S004Latency160.0
13S005Power_Consumption70.0
14S005Error_Rate15.0
15S005Latency300.0
16S006Power_Consumption25.0
17S006Error_Rate2.0
18S006Latency110.0
19S007Power_Consumption15.0
20S007Error_Rate1.0
21S007Latency70.0
22S008Power_Consumption60.0
23S008Error_Rate10.0
24S008Latency220.0
25S009Power_Consumption45.0
26S009Error_Rate6.0
27S009Latency180.0
28S010Power_Consumption30.0
29S010Error_Rate3.0
30S010Latency100.0
31S011Power_Consumption10.0
32S011Error_Rate0.5
33S011Latency50.0
34S012Power_Consumption65.0
35S012Error_Rate12.0
36S012Latency240.0
37S013Power_Consumption38.0
38S013Error_Rate4.0
39S013Latency150.0
40S014Power_Consumption22.0
41S014Error_Rate1.0
42S014Latency90.0
43S015Power_Consumption75.0
44S015Error_Rate18.0
45S015Latency350.0
46S016Power_Consumption58.0
47S016Error_Rate9.0
48S016Latency210.0

13. APPEND, MERGE, SET

data new_sensors;

  input Sensor_ID $ Room_Type $ Data_Frequency Power_Consumption Error_Rate Latency 

      Reliability_Score Install_Date :date9.;

  datalines;

  S017 Hall 20 28 2 95 96 20MAR2024

  S018 Office 50 62 11 230 74 25MAR2024

;

run;

proc print data=new_sensors;

run;

OUTPUT:

ObsSensor_IDRoom_TypeData_FrequencyPower_ConsumptionError_RateLatencyReliability_ScoreInstall_Date
1S017Hall20282959623455
2S018Office5062112307423460

proc append base=smart_sensors 

            data=new_sensors;

run;

proc print data=smart_sensors;

run;

OUTPUT:

ObsSensor_IDRoom_TypeData_FrequencyPower_ConsumptionError_RateLatencyReliability_ScoreInstall_DatePower_PctError_PctUtilizationTodayDays_ActiveNext_Service
1S001LivingRoom60352.01209501JAN20240.350.020Medium2414176523558
2S002Kitchen30558.02007005JAN20240.550.080Medium2414176123558
3S003Bedroom15201.0809810JAN20240.200.010Low2414175623558
4S004Bathroom45405.01608515JAN20240.400.050Medium2414175123558
5S005Garage207015.03006020JAN20240.700.150High2414174623558
6S006Hall60252.01109625JAN20240.250.020Low2414174123558
7S007Balcony10151.0709901FEB20240.150.010Low2414173423589
8S008Office506010.02207505FEB20240.600.100Low2414173023589
9S009Dining30456.01808810FEB20240.450.060Medium2414172523589
10S010KidsRoom20303.01009415FEB20240.300.030Low2414172023589
11S011StoreRoom10100.55010020FEB20240.100.005Low2414171523589
12S012Kitchen256512.02407225FEB20240.650.120High2414171023589
13S013LivingRoom55384.01509001MAR20240.380.040Medium2414170523620
14S014Bedroom15221.0909705MAR20240.220.010Low2414170123620
15S015Garage307518.03505510MAR20240.750.180High2414169623620
16S016Office60589.02107815MAR20240.580.090Medium2414169123620
17S017Hall20282.0959620MAR2024.. ...
18S018Office506211.02307425MAR2024.. ...

proc sort data=smart_sensors;by Sensor_ID;run;

proc print data=smart_sensors;

run;

OUTPUT:

ObsSensor_IDRoom_TypeData_FrequencyPower_ConsumptionError_RateLatencyReliability_ScoreInstall_DatePower_PctError_PctUtilizationTodayDays_ActiveNext_Service
1S001LivingRoom60352.01209501JAN20240.350.020Medium2414176523558
2S002Kitchen30558.02007005JAN20240.550.080Medium2414176123558
3S003Bedroom15201.0809810JAN20240.200.010Low2414175623558
4S004Bathroom45405.01608515JAN20240.400.050Medium2414175123558
5S005Garage207015.03006020JAN20240.700.150High2414174623558
6S006Hall60252.01109625JAN20240.250.020Low2414174123558
7S007Balcony10151.0709901FEB20240.150.010Low2414173423589
8S008Office506010.02207505FEB20240.600.100Low2414173023589
9S009Dining30456.01808810FEB20240.450.060Medium2414172523589
10S010KidsRoom20303.01009415FEB20240.300.030Low2414172023589
11S011StoreRoom10100.55010020FEB20240.100.005Low2414171523589
12S012Kitchen256512.02407225FEB20240.650.120High2414171023589
13S013LivingRoom55384.01509001MAR20240.380.040Medium2414170523620
14S014Bedroom15221.0909705MAR20240.220.010Low2414170123620
15S015Garage307518.03505510MAR20240.750.180High2414169623620
16S016Office60589.02107815MAR20240.580.090Medium2414169123620
17S017Hall20282.0959620MAR2024.. ...
18S018Office506211.02307425MAR2024.. ...

proc sort data=fraud_sensors;by Sensor_ID;run;

proc print data=fraud_sensors;

run;

OUTPUT:

ObsSensor_IDRoom_TypeData_FrequencyPower_ConsumptionError_RateLatencyReliability_ScoreInstall_DatePower_PctError_PctUtilizationTodayDays_ActiveNext_ServiceFraud_Flag
1S001LivingRoom60352.01209501JAN20240.350.020Medium2414176523558NO
2S002Kitchen30558.02007005JAN20240.550.080Medium2414176123558NO
3S003Bedroom15201.0809810JAN20240.200.010Low2414175623558NO
4S004Bathroom45405.01608515JAN20240.400.050Medium2414175123558NO
5S005Garage207015.03006020JAN20240.700.150High2414174623558YES
6S006Hall60252.01109625JAN20240.250.020Low2414174123558NO
7S007Balcony10151.0709901FEB20240.150.010Low2414173423589NO
8S008Office506010.02207505FEB20240.600.100Low2414173023589NO
9S009Dining30456.01808810FEB20240.450.060Medium2414172523589NO
10S010KidsRoom20303.01009415FEB20240.300.030Low2414172023589NO
11S011StoreRoom10100.55010020FEB20240.100.005Low2414171523589NO
12S012Kitchen256512.02407225FEB20240.650.120High2414171023589YES
13S013LivingRoom55384.01509001MAR20240.380.040Medium2414170523620NO
14S014Bedroom15221.0909705MAR20240.220.010Low2414170123620NO
15S015Garage307518.03505510MAR20240.750.180High2414169623620YES
16S016Office60589.02107815MAR20240.580.090Medium2414169123620NO

data merged;

merge smart_sensors 

      fraud_sensors;

by Sensor_ID;

run;

proc print data=merged;

run;

OUTPUT:

ObsSensor_IDRoom_TypeData_FrequencyPower_ConsumptionError_RateLatencyReliability_ScoreInstall_DatePower_PctError_PctUtilizationTodayDays_ActiveNext_ServiceFraud_Flag
1S001LivingRoom60352.01209501JAN20240.350.020Medium2414176523558NO
2S002Kitchen30558.02007005JAN20240.550.080Medium2414176123558NO
3S003Bedroom15201.0809810JAN20240.200.010Low2414175623558NO
4S004Bathroom45405.01608515JAN20240.400.050Medium2414175123558NO
5S005Garage207015.03006020JAN20240.700.150High2414174623558YES
6S006Hall60252.01109625JAN20240.250.020Low2414174123558NO
7S007Balcony10151.0709901FEB20240.150.010Low2414173423589NO
8S008Office506010.02207505FEB20240.600.100Low2414173023589NO
9S009Dining30456.01808810FEB20240.450.060Medium2414172523589NO
10S010KidsRoom20303.01009415FEB20240.300.030Low2414172023589NO
11S011StoreRoom10100.55010020FEB20240.100.005Low2414171523589NO
12S012Kitchen256512.02407225FEB20240.650.120High2414171023589YES
13S013LivingRoom55384.01509001MAR20240.380.040Medium2414170523620NO
14S014Bedroom15221.0909705MAR20240.220.010Low2414170123620NO
15S015Garage307518.03505510MAR20240.750.180High2414169623620YES
16S016Office60589.02107815MAR20240.580.090Medium2414169123620NO
17S017Hall20282.0959620MAR2024.. ... 
18S018Office506211.02307425MAR2024.. ... 

14. CHARACTER FUNCTIONS

data smart_sensors;

    set smart_sensors;

    Sensor_Clean = strip(Sensor_ID);

    Room_Upper = upcase(Room_Type);

    Room_Lower = lowcase(Room_Type);

    Room_Proper = propcase(Room_Type);

    Label = catx("-", Sensor_ID, Room_Type);

run;

proc print data=smart_sensors;

 var Sensor_ID Room_Type Sensor_Clean Room_Upper Room_Lower Label;

run;

OUTPUT:

ObsSensor_IDRoom_TypeSensor_CleanRoom_UpperRoom_LowerLabel
1S001LivingRoomS001LIVINGROOMlivingroomS001-LivingRoom
2S002KitchenS002KITCHENkitchenS002-Kitchen
3S003BedroomS003BEDROOMbedroomS003-Bedroom
4S004BathroomS004BATHROOMbathroomS004-Bathroom
5S005GarageS005GARAGEgarageS005-Garage
6S006HallS006HALLhallS006-Hall
7S007BalconyS007BALCONYbalconyS007-Balcony
8S008OfficeS008OFFICEofficeS008-Office
9S009DiningS009DININGdiningS009-Dining
10S010KidsRoomS010KIDSROOMkidsroomS010-KidsRoom
11S011StoreRoomS011STOREROOMstoreroomS011-StoreRoom
12S012KitchenS012KITCHENkitchenS012-Kitchen
13S013LivingRoomS013LIVINGROOMlivingroomS013-LivingRoom
14S014BedroomS014BEDROOMbedroomS014-Bedroom
15S015GarageS015GARAGEgarageS015-Garage
16S016OfficeS016OFFICEofficeS016-Office
17S017HallS017HALLhallS017-Hall
18S018OfficeS018OFFICEofficeS018-Office

15. PROC DATASETS DELETE

proc datasets library=work;

  delete transposed;

run;

quit;

LOG:

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

16. KEY BUSINESS INSIGHTS

From the analysis of smart home sensor data, several important insights can be derived:

  • Sensors installed in Garages and Kitchens tend to consume more power.
  • Higher latency generally leads to lower reliability scores.
  • Sensors with error rates above 10% show suspicious behavior and require investigation.
  • Older sensors show declining performance compared to recently installed ones.
  • Rooms with more automation devices generate higher data frequency.

These insights help organizations optimize infrastructure and improve customer satisfaction.

17. PRACTICAL APPLICATIONS

This type of analytics system is used in real-world scenarios such as:

  • Smart city monitoring
  • Energy management systems
  • Hospital automation
  • Industrial IoT platforms
  • Security surveillance systems
  • Predictive maintenance systems

18. INTERVIEW AND CAREER RELEVANCE

This project is highly valuable for:

  • SAS Programmer interviews
  • Data Analyst roles
  • IoT analytics positions
  • Business intelligence profiles

It demonstrates skills in:

  • Data engineering
  • Statistical analysis
  • SQL programming
  • Automation
  • Visualization
  • Business interpretation

Recruiters prefer candidates who can explain:

  • Business problem
  • Data logic
  • Technical implementation
  • Insights and conclusions

This project fulfills all those expectations.

CONCLUSION

The Smart Home Sensors Analytics using SAS project provides a complete demonstration of how real-world IoT data can be analyzed using SAS. Starting from data creation to final business insights, the project covers every important stage of the analytics lifecycle.

By implementing statistical procedures, SQL queries, macros, and visualization techniques, this project successfully transforms raw sensor data into actionable intelligence. It highlights the importance of monitoring sensor performance, detecting anomalies, and ensuring system reliability in smart environments.

From a learning perspective, this project strengthens understanding of core SAS concepts such as data steps, procedures, macros, functions, and reporting. From a business perspective, it shows how data analytics supports operational efficiency, cost reduction, risk management, and strategic planning.

In summary, this project acts as a bridge between technical SAS programming skills and real-world business applications, making it an ideal case study for both academic learning and professional development.


INTERVIEW QUESTIONS FOR YOU

·  What is %DO and %END?

·  What is %PUT?

·  What is the difference between local and global macro variables?

 

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

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 SMART HOME 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 and smart cities

·  EV and energy industry professionals

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

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.Can SAS Predict Airline Disasters Before They Happen?

2.Which Indian Cuisine Dominates the Restaurant Market? Complete Sas Data

3.Which Is the Most Spoken Language in India?Complete Sas Data

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

About Us | Contact Privacy Policy

Comments

Popular posts from this blog

379.CAN SAS DELIVER END-TO-END TLF (TABLES, LISTINGS, AND FIGURES) FOR INSURANCE CLAIMS ANALYSIS?

184.HOW TO CREATE MOCK SHELLS AND CLINICAL DATA LISTINGS IN SAS USING DATA NULL | PROC PRINT | PROC REPORT | PROC SORT | PROC COMPARE | ODS PDF | ODS RTF | ODS EXCEL | A COMPLETE STEP-BY-STEP GUIDE FOR CLINICAL SAS PROGRAMMERS

383.Which Pharma Distributors Are High-Risk? Can SAS Detect Delays, Temperature Violations, and Fraud?