376.How Do You Build a Real-World Weather Analytics System in SAS?
How Do You Build a Real-World Weather Analytics System in SAS?
1. Business & Analytical Context
Weather
stations play a critical role in:
- Climate monitoring
- Disaster prediction
- Agriculture planning
- Aviation and logistics
- Environmental research
From an
analytics perspective, weather station data is time-dependent,
numeric-heavy, and quality-sensitive.
Therefore, it is ideal for demonstrating:
- Date handling
- Numeric aggregation
- Correlation analysis
- Data standardization
- Macro-based classification
- Dataset lifecycle management
2. Project Objectives
Here We Learn :
1.
Create a Weather
Stations dataset with 15+
observations
2.
Apply date
intelligence using:
o MDY
o INTCK
o INTNX
3.
Use character
functions for standardization
4.
Use numeric
functions for analytics
5.
Build a macro-based
reliability grading system
6.
Perform:
o PROC
SQL
o PROC
MEANS
o PROC
CORR
o PROC
FORMAT
7. Demonstrate:
o TRANSPOSE
o PROC
DATASETS DELETE
3. Dataset Design
Core Variables
|
Variable |
Type |
Description |
|
Station_Name |
Character |
Weather station identifier |
|
Country |
Character |
Country |
|
Avg_Temperature |
Numeric |
Average temperature (°C) |
|
Rainfall_mm |
Numeric |
Annual rainfall (mm) |
|
Wind_Speed |
Numeric |
Average wind speed (km/h) |
|
Accuracy_Score |
Numeric |
Instrument accuracy (0–100) |
|
Start_Date |
Date |
Operational start date |
|
End_Date |
Date |
Operational end date |
|
Operational_Years |
Numeric |
Derived operational duration |
4. Create Base Weather Station Dataset
data weather_base;
length Station_Name $30 Country $20;
format Start_Date End_Date date9.;
input Station_Name $ Country $ Avg_Temperature Rainfall_mm Wind_Speed
Accuracy_Score Start_Date : date9. End_Date : date9.;
datalines;
Hyderabad_Central India 28.5 820 12.4 91 01JAN2000 31DEC2024
Delhi_North India 26.1 740 14.8 88 15MAR1998 31DEC2024
Mumbai_Coastal India 29.2 2200 18.6 94 01JAN1995 31DEC2024
Chennai_East India 30.1 1350 16.2 89 10JUN2001 31DEC2024
Kolkata_East India 27.8 1600 13.9 90 01JAN1997 31DEC2024
Jaipur_West India 25.4 520 11.1 85 01JAN2002 31DEC2024
Bengaluru_South India 24.3 970 10.5 92 01JAN1999 31DEC2024
Pune_West India 26.2 720 12.9 87 01JAN2003 31DEC2024
Ahmedabad_West India 27.6 690 15.4 86 01JAN2000 31DEC2024
Nagpur_Central India 28.1 1050 13.2 88 01JAN2001 31DEC2024
Bhopal_Central India 26.9 1140 11.8 90 01JAN2004 31DEC2024
Indore_Central India 25.8 980 12.0 89 01JAN2005 31DEC2024
Lucknow_North India 27.2 1010 13.5 87 01JAN1996 31DEC2024
Patna_East India 28.0 1200 14.1 86 01JAN1997 31DEC2024
Surat_West India 29.0 1400 16.5 91 01JAN2000 31DEC2024
;
run;
proc print data=weather_base;
run;
OUTPUT:
| Obs | Station_Name | Country | Start_Date | End_Date | Avg_Temperature | Rainfall_mm | Wind_Speed | Accuracy_Score |
|---|---|---|---|---|---|---|---|---|
| 1 | Hyderabad_Central | India | 01JAN2000 | 31DEC2024 | 28.5 | 820 | 12.4 | 91 |
| 2 | Delhi_North | India | 15MAR1998 | 31DEC2024 | 26.1 | 740 | 14.8 | 88 |
| 3 | Mumbai_Coastal | India | 01JAN1995 | 31DEC2024 | 29.2 | 2200 | 18.6 | 94 |
| 4 | Chennai_East | India | 10JUN2001 | 31DEC2024 | 30.1 | 1350 | 16.2 | 89 |
| 5 | Kolkata_East | India | 01JAN1997 | 31DEC2024 | 27.8 | 1600 | 13.9 | 90 |
| 6 | Jaipur_West | India | 01JAN2002 | 31DEC2024 | 25.4 | 520 | 11.1 | 85 |
| 7 | Bengaluru_South | India | 01JAN1999 | 31DEC2024 | 24.3 | 970 | 10.5 | 92 |
| 8 | Pune_West | India | 01JAN2003 | 31DEC2024 | 26.2 | 720 | 12.9 | 87 |
| 9 | Ahmedabad_West | India | 01JAN2000 | 31DEC2024 | 27.6 | 690 | 15.4 | 86 |
| 10 | Nagpur_Central | India | 01JAN2001 | 31DEC2024 | 28.1 | 1050 | 13.2 | 88 |
| 11 | Bhopal_Central | India | 01JAN2004 | 31DEC2024 | 26.9 | 1140 | 11.8 | 90 |
| 12 | Indore_Central | India | 01JAN2005 | 31DEC2024 | 25.8 | 980 | 12.0 | 89 |
| 13 | Lucknow_North | India | 01JAN1996 | 31DEC2024 | 27.2 | 1010 | 13.5 | 87 |
| 14 | Patna_East | India | 01JAN1997 | 31DEC2024 | 28.0 | 1200 | 14.1 | 86 |
| 15 | Surat_West | India | 01JAN2000 | 31DEC2024 | 29.0 | 1400 | 16.5 | 91 |
Explanation
·
LENGTH defines character size early to
prevent truncation
·
FORMAT date9. ensures readable dates
·
Realistic climate data improves analytical
credibility
5. Derive Operational Years Using INTCK
data weather_years;
set weather_base;
Operational_Years = intck('year', Start_Date, End_Date, 'c');
run;
proc print data=weather_years;
run;
OUTPUT:
| Obs | Station_Name | Country | Start_Date | End_Date | Avg_Temperature | Rainfall_mm | Wind_Speed | Accuracy_Score | Operational_Years |
|---|---|---|---|---|---|---|---|---|---|
| 1 | Hyderabad_Central | India | 01JAN2000 | 31DEC2024 | 28.5 | 820 | 12.4 | 91 | 24 |
| 2 | Delhi_North | India | 15MAR1998 | 31DEC2024 | 26.1 | 740 | 14.8 | 88 | 26 |
| 3 | Mumbai_Coastal | India | 01JAN1995 | 31DEC2024 | 29.2 | 2200 | 18.6 | 94 | 29 |
| 4 | Chennai_East | India | 10JUN2001 | 31DEC2024 | 30.1 | 1350 | 16.2 | 89 | 23 |
| 5 | Kolkata_East | India | 01JAN1997 | 31DEC2024 | 27.8 | 1600 | 13.9 | 90 | 27 |
| 6 | Jaipur_West | India | 01JAN2002 | 31DEC2024 | 25.4 | 520 | 11.1 | 85 | 22 |
| 7 | Bengaluru_South | India | 01JAN1999 | 31DEC2024 | 24.3 | 970 | 10.5 | 92 | 25 |
| 8 | Pune_West | India | 01JAN2003 | 31DEC2024 | 26.2 | 720 | 12.9 | 87 | 21 |
| 9 | Ahmedabad_West | India | 01JAN2000 | 31DEC2024 | 27.6 | 690 | 15.4 | 86 | 24 |
| 10 | Nagpur_Central | India | 01JAN2001 | 31DEC2024 | 28.1 | 1050 | 13.2 | 88 | 23 |
| 11 | Bhopal_Central | India | 01JAN2004 | 31DEC2024 | 26.9 | 1140 | 11.8 | 90 | 20 |
| 12 | Indore_Central | India | 01JAN2005 | 31DEC2024 | 25.8 | 980 | 12.0 | 89 | 19 |
| 13 | Lucknow_North | India | 01JAN1996 | 31DEC2024 | 27.2 | 1010 | 13.5 | 87 | 28 |
| 14 | Patna_East | India | 01JAN1997 | 31DEC2024 | 28.0 | 1200 | 14.1 | 86 | 27 |
| 15 | Surat_West | India | 01JAN2000 | 31DEC2024 | 29.0 | 1400 | 16.5 | 91 | 24 |
Why INTCK?
·
INTCK counts calendar boundaries crossed
·
'c' option ensures continuous year calculation
·
Used heavily in exposure, duration, survival analysis
data weather_clean;
set weather_years;
Station_Clean = propcase(scan(Station_Name, 1, '_'));
Country_Upper = upcase(Country);
Country_Lower = lowcase(Country);
Station_Tag = catx('-', Station_Clean, Country_Upper);
Station_Code = substr(Station_Name, 1, 3);
Station_Final = strip(trim(Station_Tag));
run;
proc print data=weather_clean;
run;
OUTPUT:
| Obs | Station_Name | Country | Start_Date | End_Date | Avg_Temperature | Rainfall_mm | Wind_Speed | Accuracy_Score | Operational_Years | Station_Clean | Country_Upper | Country_Lower | Station_Tag | Station_Code | Station_Final |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Hyderabad_Central | India | 01JAN2000 | 31DEC2024 | 28.5 | 820 | 12.4 | 91 | 24 | Hyderabad | INDIA | india | Hyderabad-INDIA | Hyd | Hyderabad-INDIA |
| 2 | Delhi_North | India | 15MAR1998 | 31DEC2024 | 26.1 | 740 | 14.8 | 88 | 26 | Delhi | INDIA | india | Delhi-INDIA | Del | Delhi-INDIA |
| 3 | Mumbai_Coastal | India | 01JAN1995 | 31DEC2024 | 29.2 | 2200 | 18.6 | 94 | 29 | Mumbai | INDIA | india | Mumbai-INDIA | Mum | Mumbai-INDIA |
| 4 | Chennai_East | India | 10JUN2001 | 31DEC2024 | 30.1 | 1350 | 16.2 | 89 | 23 | Chennai | INDIA | india | Chennai-INDIA | Che | Chennai-INDIA |
| 5 | Kolkata_East | India | 01JAN1997 | 31DEC2024 | 27.8 | 1600 | 13.9 | 90 | 27 | Kolkata | INDIA | india | Kolkata-INDIA | Kol | Kolkata-INDIA |
| 6 | Jaipur_West | India | 01JAN2002 | 31DEC2024 | 25.4 | 520 | 11.1 | 85 | 22 | Jaipur | INDIA | india | Jaipur-INDIA | Jai | Jaipur-INDIA |
| 7 | Bengaluru_South | India | 01JAN1999 | 31DEC2024 | 24.3 | 970 | 10.5 | 92 | 25 | Bengaluru | INDIA | india | Bengaluru-INDIA | Ben | Bengaluru-INDIA |
| 8 | Pune_West | India | 01JAN2003 | 31DEC2024 | 26.2 | 720 | 12.9 | 87 | 21 | Pune | INDIA | india | Pune-INDIA | Pun | Pune-INDIA |
| 9 | Ahmedabad_West | India | 01JAN2000 | 31DEC2024 | 27.6 | 690 | 15.4 | 86 | 24 | Ahmedabad | INDIA | india | Ahmedabad-INDIA | Ahm | Ahmedabad-INDIA |
| 10 | Nagpur_Central | India | 01JAN2001 | 31DEC2024 | 28.1 | 1050 | 13.2 | 88 | 23 | Nagpur | INDIA | india | Nagpur-INDIA | Nag | Nagpur-INDIA |
| 11 | Bhopal_Central | India | 01JAN2004 | 31DEC2024 | 26.9 | 1140 | 11.8 | 90 | 20 | Bhopal | INDIA | india | Bhopal-INDIA | Bho | Bhopal-INDIA |
| 12 | Indore_Central | India | 01JAN2005 | 31DEC2024 | 25.8 | 980 | 12.0 | 89 | 19 | Indore | INDIA | india | Indore-INDIA | Ind | Indore-INDIA |
| 13 | Lucknow_North | India | 01JAN1996 | 31DEC2024 | 27.2 | 1010 | 13.5 | 87 | 28 | Lucknow | INDIA | india | Lucknow-INDIA | Luc | Lucknow-INDIA |
| 14 | Patna_East | India | 01JAN1997 | 31DEC2024 | 28.0 | 1200 | 14.1 | 86 | 27 | Patna | INDIA | india | Patna-INDIA | Pat | Patna-INDIA |
| 15 | Surat_West | India | 01JAN2000 | 31DEC2024 | 29.0 | 1400 | 16.5 | 91 | 24 | Surat | INDIA | india | Surat-INDIA | Sur | Surat-INDIA |
Why These Functions Matter
|
Function |
Purpose |
|
|
Token extraction |
|
|
Reporting quality |
|
|
Clean concatenation |
|
|
Whitespace removal |
|
|
Code creation |
7. Numeric Functions
data weather_numeric;
set weather_clean;
Climate_Score = mean(Avg_Temperature, Rainfall_mm/100, Wind_Speed);
Rounded_Score = round(Climate_Score, 0.1);
Integer_Score = int(Rounded_Score);
Total_Measure = sum(Avg_Temperature, Rainfall_mm, Wind_Speed);
Median_Measure = median(Avg_Temperature, Rainfall_mm, Wind_Speed);
run;
proc print data=weather_numeric;
run;
OUTPUT:
| Obs | Station_Name | Country | Start_Date | End_Date | Avg_Temperature | Rainfall_mm | Wind_Speed | Accuracy_Score | Operational_Years | Station_Clean | Country_Upper | Country_Lower | Station_Tag | Station_Code | Station_Final | Climate_Score | Rounded_Score | Integer_Score | Total_Measure | Median_Measure |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Hyderabad_Central | India | 01JAN2000 | 31DEC2024 | 28.5 | 820 | 12.4 | 91 | 24 | Hyderabad | INDIA | india | Hyderabad-INDIA | Hyd | Hyderabad-INDIA | 16.3667 | 16.4 | 16 | 860.9 | 28.5 |
| 2 | Delhi_North | India | 15MAR1998 | 31DEC2024 | 26.1 | 740 | 14.8 | 88 | 26 | Delhi | INDIA | india | Delhi-INDIA | Del | Delhi-INDIA | 16.1000 | 16.1 | 16 | 780.9 | 26.1 |
| 3 | Mumbai_Coastal | India | 01JAN1995 | 31DEC2024 | 29.2 | 2200 | 18.6 | 94 | 29 | Mumbai | INDIA | india | Mumbai-INDIA | Mum | Mumbai-INDIA | 23.2667 | 23.3 | 23 | 2247.8 | 29.2 |
| 4 | Chennai_East | India | 10JUN2001 | 31DEC2024 | 30.1 | 1350 | 16.2 | 89 | 23 | Chennai | INDIA | india | Chennai-INDIA | Che | Chennai-INDIA | 19.9333 | 19.9 | 19 | 1396.3 | 30.1 |
| 5 | Kolkata_East | India | 01JAN1997 | 31DEC2024 | 27.8 | 1600 | 13.9 | 90 | 27 | Kolkata | INDIA | india | Kolkata-INDIA | Kol | Kolkata-INDIA | 19.2333 | 19.2 | 19 | 1641.7 | 27.8 |
| 6 | Jaipur_West | India | 01JAN2002 | 31DEC2024 | 25.4 | 520 | 11.1 | 85 | 22 | Jaipur | INDIA | india | Jaipur-INDIA | Jai | Jaipur-INDIA | 13.9000 | 13.9 | 13 | 556.5 | 25.4 |
| 7 | Bengaluru_South | India | 01JAN1999 | 31DEC2024 | 24.3 | 970 | 10.5 | 92 | 25 | Bengaluru | INDIA | india | Bengaluru-INDIA | Ben | Bengaluru-INDIA | 14.8333 | 14.8 | 14 | 1004.8 | 24.3 |
| 8 | Pune_West | India | 01JAN2003 | 31DEC2024 | 26.2 | 720 | 12.9 | 87 | 21 | Pune | INDIA | india | Pune-INDIA | Pun | Pune-INDIA | 15.4333 | 15.4 | 15 | 759.1 | 26.2 |
| 9 | Ahmedabad_West | India | 01JAN2000 | 31DEC2024 | 27.6 | 690 | 15.4 | 86 | 24 | Ahmedabad | INDIA | india | Ahmedabad-INDIA | Ahm | Ahmedabad-INDIA | 16.6333 | 16.6 | 16 | 733.0 | 27.6 |
| 10 | Nagpur_Central | India | 01JAN2001 | 31DEC2024 | 28.1 | 1050 | 13.2 | 88 | 23 | Nagpur | INDIA | india | Nagpur-INDIA | Nag | Nagpur-INDIA | 17.2667 | 17.3 | 17 | 1091.3 | 28.1 |
| 11 | Bhopal_Central | India | 01JAN2004 | 31DEC2024 | 26.9 | 1140 | 11.8 | 90 | 20 | Bhopal | INDIA | india | Bhopal-INDIA | Bho | Bhopal-INDIA | 16.7000 | 16.7 | 16 | 1178.7 | 26.9 |
| 12 | Indore_Central | India | 01JAN2005 | 31DEC2024 | 25.8 | 980 | 12.0 | 89 | 19 | Indore | INDIA | india | Indore-INDIA | Ind | Indore-INDIA | 15.8667 | 15.9 | 15 | 1017.8 | 25.8 |
| 13 | Lucknow_North | India | 01JAN1996 | 31DEC2024 | 27.2 | 1010 | 13.5 | 87 | 28 | Lucknow | INDIA | india | Lucknow-INDIA | Luc | Lucknow-INDIA | 16.9333 | 16.9 | 16 | 1050.7 | 27.2 |
| 14 | Patna_East | India | 01JAN1997 | 31DEC2024 | 28.0 | 1200 | 14.1 | 86 | 27 | Patna | INDIA | india | Patna-INDIA | Pat | Patna-INDIA | 18.0333 | 18.0 | 18 | 1242.1 | 28.0 |
| 15 | Surat_West | India | 01JAN2000 | 31DEC2024 | 29.0 | 1400 | 16.5 | 91 | 24 | Surat | INDIA | india | Surat-INDIA | Sur | Surat-INDIA | 19.8333 | 19.8 | 19 | 1445.5 | 29.0 |
8. Reliability Grading Macro
%macro reliability(input=, output=);
data &output;
set &input;
length Reliability $12;
if Accuracy_Score >= 90 then Reliability = "Excellent";
else if Accuracy_Score >= 85 then Reliability = "Good";
else if Accuracy_Score >= 80 then Reliability = "Average";
else Reliability = "Low";
proc print data=&output;
run;
%mend;
%reliability(input=weather_numeric, output=weather_reliable);
OUTPUT:
| Obs | Station_Name | Country | Start_Date | End_Date | Avg_Temperature | Rainfall_mm | Wind_Speed | Accuracy_Score | Operational_Years | Station_Clean | Country_Upper | Country_Lower | Station_Tag | Station_Code | Station_Final | Climate_Score | Rounded_Score | Integer_Score | Total_Measure | Median_Measure | Reliability |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Hyderabad_Central | India | 01JAN2000 | 31DEC2024 | 28.5 | 820 | 12.4 | 91 | 24 | Hyderabad | INDIA | india | Hyderabad-INDIA | Hyd | Hyderabad-INDIA | 16.3667 | 16.4 | 16 | 860.9 | 28.5 | Excellent |
| 2 | Delhi_North | India | 15MAR1998 | 31DEC2024 | 26.1 | 740 | 14.8 | 88 | 26 | Delhi | INDIA | india | Delhi-INDIA | Del | Delhi-INDIA | 16.1000 | 16.1 | 16 | 780.9 | 26.1 | Good |
| 3 | Mumbai_Coastal | India | 01JAN1995 | 31DEC2024 | 29.2 | 2200 | 18.6 | 94 | 29 | Mumbai | INDIA | india | Mumbai-INDIA | Mum | Mumbai-INDIA | 23.2667 | 23.3 | 23 | 2247.8 | 29.2 | Excellent |
| 4 | Chennai_East | India | 10JUN2001 | 31DEC2024 | 30.1 | 1350 | 16.2 | 89 | 23 | Chennai | INDIA | india | Chennai-INDIA | Che | Chennai-INDIA | 19.9333 | 19.9 | 19 | 1396.3 | 30.1 | Good |
| 5 | Kolkata_East | India | 01JAN1997 | 31DEC2024 | 27.8 | 1600 | 13.9 | 90 | 27 | Kolkata | INDIA | india | Kolkata-INDIA | Kol | Kolkata-INDIA | 19.2333 | 19.2 | 19 | 1641.7 | 27.8 | Excellent |
| 6 | Jaipur_West | India | 01JAN2002 | 31DEC2024 | 25.4 | 520 | 11.1 | 85 | 22 | Jaipur | INDIA | india | Jaipur-INDIA | Jai | Jaipur-INDIA | 13.9000 | 13.9 | 13 | 556.5 | 25.4 | Good |
| 7 | Bengaluru_South | India | 01JAN1999 | 31DEC2024 | 24.3 | 970 | 10.5 | 92 | 25 | Bengaluru | INDIA | india | Bengaluru-INDIA | Ben | Bengaluru-INDIA | 14.8333 | 14.8 | 14 | 1004.8 | 24.3 | Excellent |
| 8 | Pune_West | India | 01JAN2003 | 31DEC2024 | 26.2 | 720 | 12.9 | 87 | 21 | Pune | INDIA | india | Pune-INDIA | Pun | Pune-INDIA | 15.4333 | 15.4 | 15 | 759.1 | 26.2 | Good |
| 9 | Ahmedabad_West | India | 01JAN2000 | 31DEC2024 | 27.6 | 690 | 15.4 | 86 | 24 | Ahmedabad | INDIA | india | Ahmedabad-INDIA | Ahm | Ahmedabad-INDIA | 16.6333 | 16.6 | 16 | 733.0 | 27.6 | Good |
| 10 | Nagpur_Central | India | 01JAN2001 | 31DEC2024 | 28.1 | 1050 | 13.2 | 88 | 23 | Nagpur | INDIA | india | Nagpur-INDIA | Nag | Nagpur-INDIA | 17.2667 | 17.3 | 17 | 1091.3 | 28.1 | Good |
| 11 | Bhopal_Central | India | 01JAN2004 | 31DEC2024 | 26.9 | 1140 | 11.8 | 90 | 20 | Bhopal | INDIA | india | Bhopal-INDIA | Bho | Bhopal-INDIA | 16.7000 | 16.7 | 16 | 1178.7 | 26.9 | Excellent |
| 12 | Indore_Central | India | 01JAN2005 | 31DEC2024 | 25.8 | 980 | 12.0 | 89 | 19 | Indore | INDIA | india | Indore-INDIA | Ind | Indore-INDIA | 15.8667 | 15.9 | 15 | 1017.8 | 25.8 | Good |
| 13 | Lucknow_North | India | 01JAN1996 | 31DEC2024 | 27.2 | 1010 | 13.5 | 87 | 28 | Lucknow | INDIA | india | Lucknow-INDIA | Luc | Lucknow-INDIA | 16.9333 | 16.9 | 16 | 1050.7 | 27.2 | Good |
| 14 | Patna_East | India | 01JAN1997 | 31DEC2024 | 28.0 | 1200 | 14.1 | 86 | 27 | Patna | INDIA | india | Patna-INDIA | Pat | Patna-INDIA | 18.0333 | 18.0 | 18 | 1242.1 | 28.0 | Good |
| 15 | Surat_West | India | 01JAN2000 | 31DEC2024 | 29.0 | 1400 | 16.5 | 91 | 24 | Surat | INDIA | india | Surat-INDIA | Sur | Surat-INDIA | 19.8333 | 19.8 | 19 | 1445.5 | 29.0 | Excellent |
Why Use Macros?
·
Code reusability
·
Parameterized logic
·
Enterprise-level SAS standards
9. PROC FORMAT
proc format;
value accfmt
low-79 = 'Low'
80-84 = 'Average'
85-89 = 'Good'
90-high = 'Excellent';
run;
LOG:
10. PROC SQL Analytics
proc sql;
create table weather_sql as
select Country,
count(*) as Station_Count,
mean(Avg_Temperature) as Avg_Temp format=6.2,
mean(Accuracy_Score) as Avg_Accuracy
from weather_reliable
group by Country;
quit;
proc print data=weather_sql;
run;
OUTPUT:
| Obs | Country | Station_Count | Avg_Temp | Avg_Accuracy |
|---|---|---|---|---|
| 1 | India | 15 | 27.35 | 88.8667 |
11. PROC MEANS
proc means data=weather_reliable mean min max median;
class Reliability;
var Avg_Temperature Rainfall_mm Wind_Speed Accuracy_Score;
run;
OUTPUT:
The MEANS Procedure
| Reliability | N Obs | Variable | Mean | Minimum | Maximum | Median |
|---|---|---|---|---|---|---|
| Excellent | 6 | Avg_Temperature Rainfall_mm Wind_Speed Accuracy_Score | 27.6166667 1355.00 13.9500000 91.3333333 | 24.3000000 820.0000000 10.5000000 90.0000000 | 29.2000000 2200.00 18.6000000 94.0000000 | 28.1500000 1270.00 13.1500000 91.0000000 |
| Good | 9 | Avg_Temperature Rainfall_mm Wind_Speed Accuracy_Score | 27.1666667 917.7777778 13.6888889 87.2222222 | 25.4000000 520.0000000 11.1000000 85.0000000 | 30.1000000 1350.00 16.2000000 89.0000000 | 27.2000000 980.0000000 13.5000000 87.0000000 |
12. PROC CORR
proc corr data=weather_reliable;
var Avg_Temperature Rainfall_mm Wind_Speed Accuracy_Score;
run;
OUTPUT:
The CORR Procedure
| 4 Variables: | Avg_Temperature Rainfall_mm Wind_Speed Accuracy_Score |
|---|
| Simple Statistics | ||||||
|---|---|---|---|---|---|---|
| Variable | N | Mean | Std Dev | Sum | Minimum | Maximum |
| Avg_Temperature | 15 | 27.34667 | 1.57882 | 410.20000 | 24.30000 | 30.10000 |
| Rainfall_mm | 15 | 1093 | 424.44025 | 16390 | 520.00000 | 2200 |
| Wind_Speed | 15 | 13.79333 | 2.21019 | 206.90000 | 10.50000 | 18.60000 |
| Accuracy_Score | 15 | 88.86667 | 2.50333 | 1333 | 85.00000 | 94.00000 |
| Pearson Correlation Coefficients, N = 15 Prob > |r| under H0: Rho=0 | ||||
|---|---|---|---|---|
| Avg_Temperature | Rainfall_mm | Wind_Speed | Accuracy_Score | |
| Avg_Temperature | 1.00000 | 0.60130 0.0177 | 0.76484 0.0009 | 0.25109 0.3667 |
| Rainfall_mm | 0.60130 0.0177 | 1.00000 | 0.66055 0.0073 | 0.69077 0.0044 |
| Wind_Speed | 0.76484 0.0009 | 0.66055 0.0073 | 1.00000 | 0.28256 0.3075 |
| Accuracy_Score | 0.25109 0.3667 | 0.69077 0.0044 | 0.28256 0.3075 | 1.00000 |
·
Accuracy vs Wind → Instrument stability
·
Rainfall vs Temperature → Climate dependency
13. PROC TRANSPOSE
proc transpose data=weather_reliable
out=weather_long
name=Metric;
by Station_Final NotSorted;
var Avg_Temperature Rainfall_mm Wind_Speed Accuracy_Score;
run;
proc print data=weather_long;
run;
OUTPUT:
| Obs | Station_Final | Metric | COL1 |
|---|---|---|---|
| 1 | Hyderabad-INDIA | Avg_Temperature | 28.5 |
| 2 | Hyderabad-INDIA | Rainfall_mm | 820.0 |
| 3 | Hyderabad-INDIA | Wind_Speed | 12.4 |
| 4 | Hyderabad-INDIA | Accuracy_Score | 91.0 |
| 5 | Delhi-INDIA | Avg_Temperature | 26.1 |
| 6 | Delhi-INDIA | Rainfall_mm | 740.0 |
| 7 | Delhi-INDIA | Wind_Speed | 14.8 |
| 8 | Delhi-INDIA | Accuracy_Score | 88.0 |
| 9 | Mumbai-INDIA | Avg_Temperature | 29.2 |
| 10 | Mumbai-INDIA | Rainfall_mm | 2200.0 |
| 11 | Mumbai-INDIA | Wind_Speed | 18.6 |
| 12 | Mumbai-INDIA | Accuracy_Score | 94.0 |
| 13 | Chennai-INDIA | Avg_Temperature | 30.1 |
| 14 | Chennai-INDIA | Rainfall_mm | 1350.0 |
| 15 | Chennai-INDIA | Wind_Speed | 16.2 |
| 16 | Chennai-INDIA | Accuracy_Score | 89.0 |
| 17 | Kolkata-INDIA | Avg_Temperature | 27.8 |
| 18 | Kolkata-INDIA | Rainfall_mm | 1600.0 |
| 19 | Kolkata-INDIA | Wind_Speed | 13.9 |
| 20 | Kolkata-INDIA | Accuracy_Score | 90.0 |
| 21 | Jaipur-INDIA | Avg_Temperature | 25.4 |
| 22 | Jaipur-INDIA | Rainfall_mm | 520.0 |
| 23 | Jaipur-INDIA | Wind_Speed | 11.1 |
| 24 | Jaipur-INDIA | Accuracy_Score | 85.0 |
| 25 | Bengaluru-INDIA | Avg_Temperature | 24.3 |
| 26 | Bengaluru-INDIA | Rainfall_mm | 970.0 |
| 27 | Bengaluru-INDIA | Wind_Speed | 10.5 |
| 28 | Bengaluru-INDIA | Accuracy_Score | 92.0 |
| 29 | Pune-INDIA | Avg_Temperature | 26.2 |
| 30 | Pune-INDIA | Rainfall_mm | 720.0 |
| 31 | Pune-INDIA | Wind_Speed | 12.9 |
| 32 | Pune-INDIA | Accuracy_Score | 87.0 |
| 33 | Ahmedabad-INDIA | Avg_Temperature | 27.6 |
| 34 | Ahmedabad-INDIA | Rainfall_mm | 690.0 |
| 35 | Ahmedabad-INDIA | Wind_Speed | 15.4 |
| 36 | Ahmedabad-INDIA | Accuracy_Score | 86.0 |
| 37 | Nagpur-INDIA | Avg_Temperature | 28.1 |
| 38 | Nagpur-INDIA | Rainfall_mm | 1050.0 |
| 39 | Nagpur-INDIA | Wind_Speed | 13.2 |
| 40 | Nagpur-INDIA | Accuracy_Score | 88.0 |
| 41 | Bhopal-INDIA | Avg_Temperature | 26.9 |
| 42 | Bhopal-INDIA | Rainfall_mm | 1140.0 |
| 43 | Bhopal-INDIA | Wind_Speed | 11.8 |
| 44 | Bhopal-INDIA | Accuracy_Score | 90.0 |
| 45 | Indore-INDIA | Avg_Temperature | 25.8 |
| 46 | Indore-INDIA | Rainfall_mm | 980.0 |
| 47 | Indore-INDIA | Wind_Speed | 12.0 |
| 48 | Indore-INDIA | Accuracy_Score | 89.0 |
| 49 | Lucknow-INDIA | Avg_Temperature | 27.2 |
| 50 | Lucknow-INDIA | Rainfall_mm | 1010.0 |
| 51 | Lucknow-INDIA | Wind_Speed | 13.5 |
| 52 | Lucknow-INDIA | Accuracy_Score | 87.0 |
| 53 | Patna-INDIA | Avg_Temperature | 28.0 |
| 54 | Patna-INDIA | Rainfall_mm | 1200.0 |
| 55 | Patna-INDIA | Wind_Speed | 14.1 |
| 56 | Patna-INDIA | Accuracy_Score | 86.0 |
| 57 | Surat-INDIA | Avg_Temperature | 29.0 |
| 58 | Surat-INDIA | Rainfall_mm | 1400.0 |
| 59 | Surat-INDIA | Wind_Speed | 16.5 |
| 60 | Surat-INDIA | Accuracy_Score | 91.0 |
14. PROC DATASETS DELETE
proc datasets library=work nolist;
delete weather_base weather_years weather_clean weather_numeric;
quit;
OUTPUT:
NOTE: Deleting WORK.WEATHER_BASE (memtype=DATA). NOTE: Deleting WORK.WEATHER_YEARS (memtype=DATA). NOTE: Deleting WORK.WEATHER_CLEAN (memtype=DATA). NOTE: Deleting WORK.WEATHER_NUMERIC (memtype=DATA).
15. Interview-Ready Highlights
·
Demonstrates full SAS lifecycle
·
Uses all
core Base SAS functions
·
Strong date intelligence
·
Macro-driven classification
·
Clean dataset management
·
Production-quality structure
16. Final Conclusion
This project demonstrates how SAS functions as a complete analytics ecosystem,
not merely a reporting tool.
From raw data creation to statistical validation and reliability grading,
every step mirrors real enterprise
analytics workflows.
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 Weather Stations data.
Our Mission:
This blog provides industry-focused SAS programming tutorials and analytics projects covering finance, healthcare, and technology.
This project is suitable for:
SAS Programmer Interviews
SAS Programmer Job Seekers
SAS Analysts
Comments
Post a Comment