CREATION, SORTING, ANALYSIS, AND YEARLY REPORT GENERATION OF INDIAN NEWS CHANNEL DATA USING PROC PRINT, PROC SORT, AND PROC SQL WITH MACRO AUTOMATION
1. CREATE THE DATASET
options nocenter;
%macro News_India;
filename News Temp;
data _null_;
file News;
put "101 NDTV National 75 2024 4.7";
put "102 AajTak National 90 2024 4.8";
put "103 RepublicTV Politics 85 2024 4.6";
put "104 IndiaTV General 65 2023 4.3";
put "105 ABPNews National 70 2023 4.4";
put "106 ZeeNews Politics 60 2024 4.2";
put "107 TimesNow English 68 2024 4.5";
put "108 News18 Regional 50 2023 4.1";
put "109 TV9Telugu Regional 45 2024 4.3";
put "110 ETVBharat Regional 55 2024 4.4";
put "111 Wion English 40 2023 4.6";
put "112 CNNNews18 English 38 2024 4.5";
run;
data work.News_Channels;
infile News;
input NewsID ChannelName :$20. Category :$15. Viewers_Lakh Year Rating;
run;
2. DISPLAY THE DATASET
title "NEWS INDIA DATASET: LIST OF POPULAR CHANNELS AND RATINGS";
proc print data=News_Channels noobs label;
label
NewsID = "Channel ID"
ChannelName = "News Channel Name"
Category = "Category Type"
Viewers_Lakh = "Viewership (in Lakhs)"
Year = "Year of Survey"
Rating = "Viewer Rating (1-5)";
run;
%Mend;
%News_India;
OUTPUT:
| Channel ID | News Channel Name | Category Type | Viewership (in Lakhs) | Year of Survey | Viewer Rating (1-5) |
|---|---|---|---|---|---|
| 101 | NDTV | National | 75 | 2024 | 4.7 |
| 102 | AajTak | National | 90 | 2024 | 4.8 |
| 103 | RepublicTV | Politics | 85 | 2024 | 4.6 |
| 104 | IndiaTV | General | 65 | 2023 | 4.3 |
| 105 | ABPNews | National | 70 | 2023 | 4.4 |
| 106 | ZeeNews | Politics | 60 | 2024 | 4.2 |
| 107 | TimesNow | English | 68 | 2024 | 4.5 |
| 108 | News18 | Regional | 50 | 2023 | 4.1 |
| 109 | TV9Telugu | Regional | 45 | 2024 | 4.3 |
| 110 | ETVBharat | Regional | 55 | 2024 | 4.4 |
| 111 | Wion | English | 40 | 2023 | 4.6 |
| 112 | CNNNews18 | English | 38 | 2024 | 4.5 |
3. Sorting The Dataset
proc sort data=News_Channels out=News_Sorted;
by Descending Viewers_Lakh;
run;
proc print data=News_Sorted;
run;
OUTPUT:
| Obs | NewsID | ChannelName | Category | Viewers_Lakh | Year | Rating |
|---|---|---|---|---|---|---|
| 1 | 102 | AajTak | National | 90 | 2024 | 4.8 |
| 2 | 103 | RepublicTV | Politics | 85 | 2024 | 4.6 |
| 3 | 101 | NDTV | National | 75 | 2024 | 4.7 |
| 4 | 105 | ABPNews | National | 70 | 2023 | 4.4 |
| 5 | 107 | TimesNow | English | 68 | 2024 | 4.5 |
| 6 | 104 | IndiaTV | General | 65 | 2023 | 4.3 |
| 7 | 106 | ZeeNews | Politics | 60 | 2024 | 4.2 |
| 8 | 110 | ETVBharat | Regional | 55 | 2024 | 4.4 |
| 9 | 108 | News18 | Regional | 50 | 2023 | 4.1 |
| 10 | 109 | TV9Telugu | Regional | 45 | 2024 | 4.3 |
| 11 | 111 | Wion | English | 40 | 2023 | 4.6 |
| 12 | 112 | CNNNews18 | English | 38 | 2024 | 4.5 |
4. Top Rated Channels (Rating = 4.6)
title "Top Rated News Channels In India(2024)";
proc sql;
select NewsID,ChannelName,Category,Viewers_Lakh,Rating
from News_Sorted
where Rating >= 4.6
Order by NewsID;
quit;
OUTPUT:
| NewsID | ChannelName | Category | Viewers_Lakh | Rating |
|---|---|---|---|---|
| 101 | NDTV | National | 75 | 4.7 |
| 102 | AajTak | National | 90 | 4.8 |
| 103 | RepublicTV | Politics | 85 | 4.6 |
| 111 | Wion | English | 40 | 4.6 |
5. Average Viewership by Category
title "AVERAGE VIEWERSHIP BY CATEGORY";
proc sql;
select NewsID,Category,Avg(Viewers_Lakh) as AvgViewers format=8.2
from News_Sorted
Group by Category;
quit;
OUTPUT:
| NewsID | Category | AvgViewers |
|---|---|---|
| 107 | English | 48.67 |
| 112 | English | 48.67 |
| 111 | English | 48.67 |
| 104 | General | 65.00 |
| 101 | National | 78.33 |
| 102 | National | 78.33 |
| 105 | National | 78.33 |
| 106 | Politics | 72.50 |
| 103 | Politics | 72.50 |
| 109 | Regional | 50.00 |
| 108 | Regional | 50.00 |
| 110 | Regional | 50.00 |
6. Macro For Yearly Report
%macro news_report(year);
title "NEWS CHANNEL REPORT FOR YEAR &year";
proc print data=News_Channels;
where year = &year;
var NewsID ChannelName Year Viewers_Lakh Rating;
run;
proc sql;
select Category,Avg(Viewers_Lakh) as AvgViewers format=8.2,
avg(Rating) as AvgRating format=3.1
from News_Channels
where year = &year
group by category;
quit;
%mend;
%news_report(2024)
OUTPUT:
| Obs | NewsID | ChannelName | Year | Viewers_Lakh | Rating |
|---|---|---|---|---|---|
| 1 | 101 | NDTV | 2024 | 75 | 4.7 |
| 2 | 102 | AajTak | 2024 | 90 | 4.8 |
| 3 | 103 | RepublicTV | 2024 | 85 | 4.6 |
| 6 | 106 | ZeeNews | 2024 | 60 | 4.2 |
| 7 | 107 | TimesNow | 2024 | 68 | 4.5 |
| 9 | 109 | TV9Telugu | 2024 | 45 | 4.3 |
| 10 | 110 | ETVBharat | 2024 | 55 | 4.4 |
| 12 | 112 | CNNNews18 | 2024 | 38 | 4.5 |
| Category | AvgViewers | AvgRating |
|---|---|---|
| English | 53.00 | 4.5 |
| National | 82.50 | 4.8 |
| Politics | 72.50 | 4.4 |
| Regional | 50.00 | 4.4 |
%news_report(2023)
OUTPUT:
| Obs | NewsID | ChannelName | Year | Viewers_Lakh | Rating |
|---|---|---|---|---|---|
| 4 | 104 | IndiaTV | 2023 | 65 | 4.3 |
| 5 | 105 | ABPNews | 2023 | 70 | 4.4 |
| 8 | 108 | News18 | 2023 | 50 | 4.1 |
| 11 | 111 | Wion | 2023 | 40 | 4.6 |
| Category | AvgViewers | AvgRating |
|---|---|---|
| English | 40.00 | 4.6 |
| General | 65.00 | 4.3 |
| National | 70.00 | 4.4 |
| Regional | 50.00 | 4.1 |
No comments:
Post a Comment