When Billions of App Downloads Meet Broken Data | Enterprise SAS and R Cleaning Frameworks That Save Analytics
FROM APP STORE CHAOS TO EXECUTIVE INTELLIGENCE
Cleaning the World's Highest Downloaded Apps
Dataset Using SAS and R
Introduction:Business Crisis Scenario
A global
mobile analytics company publishes a quarterly report identifying the world's
highest downloaded applications. Executives use the report for investment
decisions, marketing budgets, AI recommendation systems, and competitive
benchmarking.
Then
disaster strikes.
The
analytics dashboard shows:
- Negative download counts
- Duplicate App IDs
- Invalid launch dates
- Missing categories
- Corrupted country codes
- Broken email contacts
- Mixed-case application names
- Impossible ratings above 5
- Invalid timestamps
Suddenly:
- AI demand forecasting models
fail.
- Marketing budgets are
allocated incorrectly.
- Investors receive misleading
intelligence.
- Regional expansion
strategies become inaccurate.
- Regulatory reports contain
inconsistencies.
Dirty
data doesn't merely create ugly tables.
It
creates expensive business mistakes.
Global Highest Downloaded
Apps Raw Dataset
Variables (9 Variables)
|
Variable |
Description |
|
APP_ID |
Unique
App Identifier |
|
APP_NAME |
Application
Name |
|
CATEGORY |
Category |
|
COUNTRY |
Country
Code |
|
DOWNLOADS |
Total
Downloads |
|
RATING |
App
Rating |
|
RELEASE_DATE |
Release
Date |
|
SUPPORT_EMAIL |
Contact
Email |
|
ACTIVE_USERS |
Monthly
Active Users |
1.SAS Raw Dataset With Intentional Errors
data apps_raw;
length app_id $8 app_name $40 category $20 country $12
support_email $60 release_dt_raw $25;
informat release_dt_raw $25.;
infile datalines dlm='|' truncover;
input app_id $ app_name $ category $ country $ downloads
rating release_dt_raw $ support_email $active_users;
datalines;
APP001|WhatsApp|Messaging|IND|2500000000|4.8|2009-01-15|support@whatsapp.com|2000000000
APP002|facebook|Social|usa|3000000000|4.7|2004-02-04|supportfacebook.com|2500000000
APP002|facebook|Social|USA|3000000000|4.7|2004-02-04|supportfacebook.com|2500000000
APP003| TikTok |Entertainment|CHN|-1500000000|4.9|2016-09-15|help@tiktok.com|1800000000
APP004|Instagram|NULL|USA|2000000000|5.8|2010-10-06|support@instagram|1700000000
APP005|Telegram|Messaging|INDIA|900000000|4.6|2026-15-01|help@telegram.org|850000000
APP006|Snapchat|Social|UK| |4.2|2011-09-16|support@snapchat.com|700000000
APP007|CapCut|editing|chn|800000000|4.4|invalid_date|support@capcut.com|600000000
APP008|Spotify|Music|EUROPE|700000000|-2|2008-10-07|spotify.com|650000000
APP009|ChatGPT|AI|USA|900000000|4.9|2022-11-30|support@openai.com|500000000
APP010| Temu |Shopping|UsA|1200000000|4.5|2022-09-01|support@temu.com|450000000
APP011|Threads|social|USA|750000000|4.3|2023-07-05|contact@threads.com|300000000
APP012|NULL|Gaming|JPN|650000000|4.1|2020-04-20|help@gaming.com|250000000
APP013|Zoom|Business|USA|1000000000|4.7|2013-01-21|zoom@@zoom.com|400000000
APP014|Netflix|Entertainment|US|1100000000|4.8|2012-04-10|support@netflix.com|350000000
APP015|Uber|Travel|USA|950000000|4.4|2011-03-11|support@uber.com|600000000
;
run;
proc print data=apps_raw;
run;
OUTPUT:
| Obs | app_id | app_name | category | country | support_email | release_dt_raw | downloads | rating | active_users |
|---|---|---|---|---|---|---|---|---|---|
| 1 | APP001 | Messaging | IND | support@whatsapp.com | 2009-01-15 | 2500000000 | 4.8 | 2000000000 | |
| 2 | APP002 | Social | usa | supportfacebook.com | 2004-02-04 | 3000000000 | 4.7 | 2500000000 | |
| 3 | APP002 | Social | USA | supportfacebook.com | 2004-02-04 | 3000000000 | 4.7 | 2500000000 | |
| 4 | APP003 | TikTok | Entertainment | CHN | help@tiktok.com | 2016-09-15 | -1500000000 | 4.9 | 1800000000 |
| 5 | APP004 | NULL | USA | support@instagram | 2010-10-06 | 2000000000 | 5.8 | 1700000000 | |
| 6 | APP005 | Telegram | Messaging | INDIA | help@telegram.org | 2026-15-01 | 900000000 | 4.6 | 850000000 |
| 7 | APP006 | Snapchat | Social | UK | support@snapchat.com | 2011-09-16 | . | 4.2 | 700000000 |
| 8 | APP007 | CapCut | editing | chn | support@capcut.com | invalid_date | 800000000 | 4.4 | 600000000 |
| 9 | APP008 | Spotify | Music | EUROPE | spotify.com | 2008-10-07 | 700000000 | -2.0 | 650000000 |
| 10 | APP009 | ChatGPT | AI | USA | support@openai.com | 2022-11-30 | 900000000 | 4.9 | 500000000 |
| 11 | APP010 | Temu | Shopping | UsA | support@temu.com | 2022-09-01 | 1200000000 | 4.5 | 450000000 |
| 12 | APP011 | Threads | social | USA | contact@threads.com | 2023-07-05 | 750000000 | 4.3 | 300000000 |
| 13 | APP012 | NULL | Gaming | JPN | help@gaming.com | 2020-04-20 | 650000000 | 4.1 | 250000000 |
| 14 | APP013 | Zoom | Business | USA | zoom@@zoom.com | 2013-01-21 | 1000000000 | 4.7 | 400000000 |
| 15 | APP014 | Netflix | Entertainment | US | support@netflix.com | 2012-04-10 | 1100000000 | 4.8 | 350000000 |
| 16 | APP015 | Uber | Travel | USA | support@uber.com | 2011-03-11 | 950000000 | 4.4 | 600000000 |
Problems Found
|
Issue |
Impact |
|
Duplicate
APP_ID |
Double
counting downloads |
|
Negative
downloads |
Wrong
forecasting |
|
Invalid
dates |
Incorrect
trend analysis |
|
Rating
>5 |
Dashboard
errors |
|
Missing
category |
Segmentation
failures |
|
Malformed
emails |
Communication
failures |
|
Mixed
country codes |
Incorrect
regional summaries |
|
NULL
strings |
Missing
value confusion |
|
Leading
spaces |
Join
failures |
Character Truncation Risk
in SAS
One of
the biggest production issues in SAS occurs when developers place LENGTH
statements after assignments.
Bad
example:
data test;
name="International Business
Machines";
length name $10;
run;
Result:
Internatio
The
variable length was determined before the explicit LENGTH statement.
Correct
approach:
data test;
length name $50;
name="International Business
Machines";
run;
Unlike
SAS, R dynamically allocates string memory and does not suffer from character
truncation behavior.
2.SAS Cleaning Workflow
proc format;
value ratingfmt low-0='Invalid'
0<-5='Valid'
5<-high='Invalid';
run;
data apps_clean;
set apps_raw;
app_name=propcase(strip(app_name));
category=upcase(strip(category));
country=upcase(strip(country));
category=tranwrd(category,'NULL','UNKNOWN');
if downloads<0 then downloads=abs(downloads);
rating=round(rating,.1);
if rating>5 then rating=.;
format rating ratingfmt.;
if verify(support_email,
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@._')>0
then email_flag='INVALID';
release_date=input(release_dt_raw,?? yymmdd10.);
format release_date date9.;
if country in ('INDIA') then country='IND';
if country='US' then country='USA';
if country='CHN' then country='CHN';
if cmiss(of _all_)>0 then missing_flag='Y';
downloads_band=put(downloads,comma20.);
run;
proc print data=apps_clean;
run;
OUTPUT:
| Obs | app_id | app_name | category | country | support_email | release_dt_raw | downloads | rating | active_users | email_flag | release_date | missing_flag | downloads_band |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | APP001 | MESSAGING | IND | support@whatsapp.com | 2009-01-15 | 2500000000 | Valid | 2000000000 | INVALID | 15JAN2009 | 2,500,000,000 | ||
| 2 | APP002 | SOCIAL | USA | supportfacebook.com | 2004-02-04 | 3000000000 | Valid | 2500000000 | INVALID | 04FEB2004 | 3,000,000,000 | ||
| 3 | APP002 | SOCIAL | USA | supportfacebook.com | 2004-02-04 | 3000000000 | Valid | 2500000000 | INVALID | 04FEB2004 | 3,000,000,000 | ||
| 4 | APP003 | Tiktok | ENTERTAINMENT | CHN | help@tiktok.com | 2016-09-15 | 1500000000 | Valid | 1800000000 | INVALID | 15SEP2016 | 1,500,000,000 | |
| 5 | APP004 | UNKNOWN | USA | support@instagram | 2010-10-06 | 2000000000 | . | 1700000000 | INVALID | 06OCT2010 | Y | 2,000,000,000 | |
| 6 | APP005 | Telegram | MESSAGING | IND | help@telegram.org | 2026-15-01 | 900000000 | Valid | 850000000 | INVALID | . | Y | 900,000,000 |
| 7 | APP006 | Snapchat | SOCIAL | UK | support@snapchat.com | 2011-09-16 | . | Valid | 700000000 | INVALID | 16SEP2011 | Y | . |
| 8 | APP007 | Capcut | EDITING | CHN | support@capcut.com | invalid_date | 800000000 | Valid | 600000000 | INVALID | . | Y | 800,000,000 |
| 9 | APP008 | Spotify | MUSIC | EUROPE | spotify.com | 2008-10-07 | 700000000 | Invalid | 650000000 | INVALID | 07OCT2008 | 700,000,000 | |
| 10 | APP009 | Chatgpt | AI | USA | support@openai.com | 2022-11-30 | 900000000 | Valid | 500000000 | INVALID | 30NOV2022 | 900,000,000 | |
| 11 | APP010 | Temu | SHOPPING | USA | support@temu.com | 2022-09-01 | 1200000000 | Valid | 450000000 | INVALID | 01SEP2022 | 1,200,000,000 | |
| 12 | APP011 | Threads | SOCIAL | USA | contact@threads.com | 2023-07-05 | 750000000 | Valid | 300000000 | INVALID | 05JUL2023 | 750,000,000 | |
| 13 | APP012 | Null | GAMING | JPN | help@gaming.com | 2020-04-20 | 650000000 | Valid | 250000000 | INVALID | 20APR2020 | 650,000,000 | |
| 14 | APP013 | Zoom | BUSINESS | USA | zoom@@zoom.com | 2013-01-21 | 1000000000 | Valid | 400000000 | INVALID | 21JAN2013 | 1,000,000,000 | |
| 15 | APP014 | Netflix | ENTERTAINMENT | USA | support@netflix.com | 2012-04-10 | 1100000000 | Valid | 350000000 | INVALID | 10APR2012 | 1,100,000,000 | |
| 16 | APP015 | Uber | TRAVEL | USA | support@uber.com | 2011-03-11 | 950000000 | Valid | 600000000 | INVALID | 11MAR2011 | 950,000,000 |
Explanation
This
workflow demonstrates enterprise-grade cleansing logic:
- ABS() corrects impossible
download values.
- VERIFY() identifies illegal
email characters.
- TRANWRD() replaces NULL
values.
- PROPCASE() standardizes
naming.
- ROUND() controls reporting
precision.
- INPUT() converts character
dates.
- CMISS() identifies missing
values.
These
techniques appear in banking fraud systems, SDTM production pipelines, and
insurance claim processing environments.
3.Deduplication Using PROC SORT
proc sort data=apps_clean
out=apps_nodup
nodupkey;
by app_id;
run;
proc print data=apps_nodup;
run;
LOG:
OUTPUT:
| Obs | app_id | app_name | category | country | support_email | release_dt_raw | downloads | rating | active_users | email_flag | release_date | missing_flag | downloads_band |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | APP001 | MESSAGING | IND | support@whatsapp.com | 2009-01-15 | 2500000000 | Valid | 2000000000 | INVALID | 15JAN2009 | 2,500,000,000 | ||
| 2 | APP002 | SOCIAL | USA | supportfacebook.com | 2004-02-04 | 3000000000 | Valid | 2500000000 | INVALID | 04FEB2004 | 3,000,000,000 | ||
| 3 | APP003 | Tiktok | ENTERTAINMENT | CHN | help@tiktok.com | 2016-09-15 | 1500000000 | Valid | 1800000000 | INVALID | 15SEP2016 | 1,500,000,000 | |
| 4 | APP004 | UNKNOWN | USA | support@instagram | 2010-10-06 | 2000000000 | . | 1700000000 | INVALID | 06OCT2010 | Y | 2,000,000,000 | |
| 5 | APP005 | Telegram | MESSAGING | IND | help@telegram.org | 2026-15-01 | 900000000 | Valid | 850000000 | INVALID | . | Y | 900,000,000 |
| 6 | APP006 | Snapchat | SOCIAL | UK | support@snapchat.com | 2011-09-16 | . | Valid | 700000000 | INVALID | 16SEP2011 | Y | . |
| 7 | APP007 | Capcut | EDITING | CHN | support@capcut.com | invalid_date | 800000000 | Valid | 600000000 | INVALID | . | Y | 800,000,000 |
| 8 | APP008 | Spotify | MUSIC | EUROPE | spotify.com | 2008-10-07 | 700000000 | Invalid | 650000000 | INVALID | 07OCT2008 | 700,000,000 | |
| 9 | APP009 | Chatgpt | AI | USA | support@openai.com | 2022-11-30 | 900000000 | Valid | 500000000 | INVALID | 30NOV2022 | 900,000,000 | |
| 10 | APP010 | Temu | SHOPPING | USA | support@temu.com | 2022-09-01 | 1200000000 | Valid | 450000000 | INVALID | 01SEP2022 | 1,200,000,000 | |
| 11 | APP011 | Threads | SOCIAL | USA | contact@threads.com | 2023-07-05 | 750000000 | Valid | 300000000 | INVALID | 05JUL2023 | 750,000,000 | |
| 12 | APP012 | Null | GAMING | JPN | help@gaming.com | 2020-04-20 | 650000000 | Valid | 250000000 | INVALID | 20APR2020 | 650,000,000 | |
| 13 | APP013 | Zoom | BUSINESS | USA | zoom@@zoom.com | 2013-01-21 | 1000000000 | Valid | 400000000 | INVALID | 21JAN2013 | 1,000,000,000 | |
| 14 | APP014 | Netflix | ENTERTAINMENT | USA | support@netflix.com | 2012-04-10 | 1100000000 | Valid | 350000000 | INVALID | 10APR2012 | 1,100,000,000 | |
| 15 | APP015 | Uber | TRAVEL | USA | support@uber.com | 2011-03-11 | 950000000 | Valid | 600000000 | INVALID | 11MAR2011 | 950,000,000 |
Explanation
NODUPKEY
removes duplicate business keys.
Clinical
submissions often use this strategy for:
- duplicate subjects
- duplicate adverse events
- duplicate laboratory records
Failure
to deduplicate can invalidate statistical analysis.
4.PROC SQL Validation
proc sql;
create table app_summary as
select
country,
count(*) as total_apps,
sum(downloads) as total_downloads,
mean(rating) as avg_rating
from apps_nodup
group by country;
quit;
proc print data=app_summary;
run;
OUTPUT:
| Obs | country | total_apps | total_downloads | avg_rating |
|---|---|---|---|---|
| 1 | CHN | 2 | 2300000000 | 4.65000 |
| 2 | EUROPE | 1 | 700000000 | -2.00000 |
| 3 | IND | 2 | 3400000000 | 4.70000 |
| 4 | JPN | 1 | 650000000 | 4.10000 |
| 5 | UK | 1 | . | 4.20000 |
| 6 | USA | 8 | 10900000000 | 4.61429 |
Explanation
PROC SQL
excels for:
- aggregation
- joins
- validation checks
- summary reporting
5.DATA Step Alternative
proc sort data=apps_nodup;
by country;
run;
proc print data=apps_nodup;
run;
OUTPUT:
| Obs | app_id | app_name | category | country | support_email | release_dt_raw | downloads | rating | active_users | email_flag | release_date | missing_flag | downloads_band |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | APP003 | Tiktok | ENTERTAINMENT | CHN | help@tiktok.com | 2016-09-15 | 1500000000 | Valid | 1800000000 | INVALID | 15SEP2016 | 1,500,000,000 | |
| 2 | APP007 | Capcut | EDITING | CHN | support@capcut.com | invalid_date | 800000000 | Valid | 600000000 | INVALID | . | Y | 800,000,000 |
| 3 | APP008 | Spotify | MUSIC | EUROPE | spotify.com | 2008-10-07 | 700000000 | Invalid | 650000000 | INVALID | 07OCT2008 | 700,000,000 | |
| 4 | APP001 | MESSAGING | IND | support@whatsapp.com | 2009-01-15 | 2500000000 | Valid | 2000000000 | INVALID | 15JAN2009 | 2,500,000,000 | ||
| 5 | APP005 | Telegram | MESSAGING | IND | help@telegram.org | 2026-15-01 | 900000000 | Valid | 850000000 | INVALID | . | Y | 900,000,000 |
| 6 | APP012 | Null | GAMING | JPN | help@gaming.com | 2020-04-20 | 650000000 | Valid | 250000000 | INVALID | 20APR2020 | 650,000,000 | |
| 7 | APP006 | Snapchat | SOCIAL | UK | support@snapchat.com | 2011-09-16 | . | Valid | 700000000 | INVALID | 16SEP2011 | Y | . |
| 8 | APP002 | SOCIAL | USA | supportfacebook.com | 2004-02-04 | 3000000000 | Valid | 2500000000 | INVALID | 04FEB2004 | 3,000,000,000 | ||
| 9 | APP004 | UNKNOWN | USA | support@instagram | 2010-10-06 | 2000000000 | . | 1700000000 | INVALID | 06OCT2010 | Y | 2,000,000,000 | |
| 10 | APP009 | Chatgpt | AI | USA | support@openai.com | 2022-11-30 | 900000000 | Valid | 500000000 | INVALID | 30NOV2022 | 900,000,000 | |
| 11 | APP010 | Temu | SHOPPING | USA | support@temu.com | 2022-09-01 | 1200000000 | Valid | 450000000 | INVALID | 01SEP2022 | 1,200,000,000 | |
| 12 | APP011 | Threads | SOCIAL | USA | contact@threads.com | 2023-07-05 | 750000000 | Valid | 300000000 | INVALID | 05JUL2023 | 750,000,000 | |
| 13 | APP013 | Zoom | BUSINESS | USA | zoom@@zoom.com | 2013-01-21 | 1000000000 | Valid | 400000000 | INVALID | 21JAN2013 | 1,000,000,000 | |
| 14 | APP014 | Netflix | ENTERTAINMENT | USA | support@netflix.com | 2012-04-10 | 1100000000 | Valid | 350000000 | INVALID | 10APR2012 | 1,100,000,000 | |
| 15 | APP015 | Uber | TRAVEL | USA | support@uber.com | 2011-03-11 | 950000000 | Valid | 600000000 | INVALID | 11MAR2011 | 950,000,000 |
data summary_ds;
set apps_nodup;
by country;
retain total_downloads 0 total_apps 0;
total_downloads+downloads;
total_apps+1;
if last.country then output;
run;
proc print data=summary_ds;
run;
OUTPUT:
| Obs | app_id | app_name | category | country | support_email | release_dt_raw | downloads | rating | active_users | email_flag | release_date | missing_flag | downloads_band | total_downloads | total_apps |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | APP007 | Capcut | EDITING | CHN | support@capcut.com | invalid_date | 800000000 | Valid | 600000000 | INVALID | . | Y | 800,000,000 | 2300000000 | 2 |
| 2 | APP008 | Spotify | MUSIC | EUROPE | spotify.com | 2008-10-07 | 700000000 | Invalid | 650000000 | INVALID | 07OCT2008 | 700,000,000 | 3000000000 | 3 | |
| 3 | APP005 | Telegram | MESSAGING | IND | help@telegram.org | 2026-15-01 | 900000000 | Valid | 850000000 | INVALID | . | Y | 900,000,000 | 6400000000 | 5 |
| 4 | APP012 | Null | GAMING | JPN | help@gaming.com | 2020-04-20 | 650000000 | Valid | 250000000 | INVALID | 20APR2020 | 650,000,000 | 7050000000 | 6 | |
| 5 | APP006 | Snapchat | SOCIAL | UK | support@snapchat.com | 2011-09-16 | . | Valid | 700000000 | INVALID | 16SEP2011 | Y | . | 7050000000 | 7 |
| 6 | APP015 | Uber | TRAVEL | USA | support@uber.com | 2011-03-11 | 950000000 | Valid | 600000000 | INVALID | 11MAR2011 | 950,000,000 | 17950000000 | 15 |
DATA Step
provides greater row-level control compared with SQL aggregation.
6.Advanced SAS Features
6.1 ARRAY
data apps_array;
set apps_nodup;
array chars {*} app_name category country;
do i=1 to dim(chars);
chars[i]=strip(chars[i]);
end;
run;
proc print data=apps_array;
run;
OUTPUT:
| Obs | app_id | app_name | category | country | support_email | release_dt_raw | downloads | rating | active_users | email_flag | release_date | missing_flag | downloads_band | i |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | APP003 | Tiktok | ENTERTAINMENT | CHN | help@tiktok.com | 2016-09-15 | 1500000000 | Valid | 1800000000 | INVALID | 15SEP2016 | 1,500,000,000 | 4 | |
| 2 | APP007 | Capcut | EDITING | CHN | support@capcut.com | invalid_date | 800000000 | Valid | 600000000 | INVALID | . | Y | 800,000,000 | 4 |
| 3 | APP008 | Spotify | MUSIC | EUROPE | spotify.com | 2008-10-07 | 700000000 | Invalid | 650000000 | INVALID | 07OCT2008 | 700,000,000 | 4 | |
| 4 | APP001 | MESSAGING | IND | support@whatsapp.com | 2009-01-15 | 2500000000 | Valid | 2000000000 | INVALID | 15JAN2009 | 2,500,000,000 | 4 | ||
| 5 | APP005 | Telegram | MESSAGING | IND | help@telegram.org | 2026-15-01 | 900000000 | Valid | 850000000 | INVALID | . | Y | 900,000,000 | 4 |
| 6 | APP012 | Null | GAMING | JPN | help@gaming.com | 2020-04-20 | 650000000 | Valid | 250000000 | INVALID | 20APR2020 | 650,000,000 | 4 | |
| 7 | APP006 | Snapchat | SOCIAL | UK | support@snapchat.com | 2011-09-16 | . | Valid | 700000000 | INVALID | 16SEP2011 | Y | . | 4 |
| 8 | APP002 | SOCIAL | USA | supportfacebook.com | 2004-02-04 | 3000000000 | Valid | 2500000000 | INVALID | 04FEB2004 | 3,000,000,000 | 4 | ||
| 9 | APP004 | UNKNOWN | USA | support@instagram | 2010-10-06 | 2000000000 | . | 1700000000 | INVALID | 06OCT2010 | Y | 2,000,000,000 | 4 | |
| 10 | APP009 | Chatgpt | AI | USA | support@openai.com | 2022-11-30 | 900000000 | Valid | 500000000 | INVALID | 30NOV2022 | 900,000,000 | 4 | |
| 11 | APP010 | Temu | SHOPPING | USA | support@temu.com | 2022-09-01 | 1200000000 | Valid | 450000000 | INVALID | 01SEP2022 | 1,200,000,000 | 4 | |
| 12 | APP011 | Threads | SOCIAL | USA | contact@threads.com | 2023-07-05 | 750000000 | Valid | 300000000 | INVALID | 05JUL2023 | 750,000,000 | 4 | |
| 13 | APP013 | Zoom | BUSINESS | USA | zoom@@zoom.com | 2013-01-21 | 1000000000 | Valid | 400000000 | INVALID | 21JAN2013 | 1,000,000,000 | 4 | |
| 14 | APP014 | Netflix | ENTERTAINMENT | USA | support@netflix.com | 2012-04-10 | 1100000000 | Valid | 350000000 | INVALID | 10APR2012 | 1,100,000,000 | 4 | |
| 15 | APP015 | Uber | TRAVEL | USA | support@uber.com | 2011-03-11 | 950000000 | Valid | 600000000 | INVALID | 11MAR2011 | 950,000,000 | 4 |
6.2 SELECT WHEN
data apps_select;
length group $20.;
set apps_nodup;
select(category);
when('SOCIAL') group='Consumer';
when('BUSINESS') group='Enterprise';
otherwise group='Other';
end;
run;
proc print data=apps_select;
run;
OUTPUT:
| Obs | group | app_id | app_name | category | country | support_email | release_dt_raw | downloads | rating | active_users | email_flag | release_date | missing_flag | downloads_band |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Other | APP003 | Tiktok | ENTERTAINMENT | CHN | help@tiktok.com | 2016-09-15 | 1500000000 | Valid | 1800000000 | INVALID | 15SEP2016 | 1,500,000,000 | |
| 2 | Other | APP007 | Capcut | EDITING | CHN | support@capcut.com | invalid_date | 800000000 | Valid | 600000000 | INVALID | . | Y | 800,000,000 |
| 3 | Other | APP008 | Spotify | MUSIC | EUROPE | spotify.com | 2008-10-07 | 700000000 | Invalid | 650000000 | INVALID | 07OCT2008 | 700,000,000 | |
| 4 | Other | APP001 | MESSAGING | IND | support@whatsapp.com | 2009-01-15 | 2500000000 | Valid | 2000000000 | INVALID | 15JAN2009 | 2,500,000,000 | ||
| 5 | Other | APP005 | Telegram | MESSAGING | IND | help@telegram.org | 2026-15-01 | 900000000 | Valid | 850000000 | INVALID | . | Y | 900,000,000 |
| 6 | Other | APP012 | Null | GAMING | JPN | help@gaming.com | 2020-04-20 | 650000000 | Valid | 250000000 | INVALID | 20APR2020 | 650,000,000 | |
| 7 | Consumer | APP006 | Snapchat | SOCIAL | UK | support@snapchat.com | 2011-09-16 | . | Valid | 700000000 | INVALID | 16SEP2011 | Y | . |
| 8 | Consumer | APP002 | SOCIAL | USA | supportfacebook.com | 2004-02-04 | 3000000000 | Valid | 2500000000 | INVALID | 04FEB2004 | 3,000,000,000 | ||
| 9 | Other | APP004 | UNKNOWN | USA | support@instagram | 2010-10-06 | 2000000000 | . | 1700000000 | INVALID | 06OCT2010 | Y | 2,000,000,000 | |
| 10 | Other | APP009 | Chatgpt | AI | USA | support@openai.com | 2022-11-30 | 900000000 | Valid | 500000000 | INVALID | 30NOV2022 | 900,000,000 | |
| 11 | Other | APP010 | Temu | SHOPPING | USA | support@temu.com | 2022-09-01 | 1200000000 | Valid | 450000000 | INVALID | 01SEP2022 | 1,200,000,000 | |
| 12 | Consumer | APP011 | Threads | SOCIAL | USA | contact@threads.com | 2023-07-05 | 750000000 | Valid | 300000000 | INVALID | 05JUL2023 | 750,000,000 | |
| 13 | Enterprise | APP013 | Zoom | BUSINESS | USA | zoom@@zoom.com | 2013-01-21 | 1000000000 | Valid | 400000000 | INVALID | 21JAN2013 | 1,000,000,000 | |
| 14 | Other | APP014 | Netflix | ENTERTAINMENT | USA | support@netflix.com | 2012-04-10 | 1100000000 | Valid | 350000000 | INVALID | 10APR2012 | 1,100,000,000 | |
| 15 | Other | APP015 | Uber | TRAVEL | USA | support@uber.com | 2011-03-11 | 950000000 | Valid | 600000000 | INVALID | 11MAR2011 | 950,000,000 |
6.3 RETAIN
data apps_retain;
set apps_nodup;
retain cumulative_downloads 0;
cumulative_downloads+downloads;
run;
proc print data=apps_retain;
run;
OUTPUT:
| Obs | app_id | app_name | category | country | support_email | release_dt_raw | downloads | rating | active_users | email_flag | release_date | missing_flag | downloads_band | cumulative_downloads |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | APP003 | Tiktok | ENTERTAINMENT | CHN | help@tiktok.com | 2016-09-15 | 1500000000 | Valid | 1800000000 | INVALID | 15SEP2016 | 1,500,000,000 | 1500000000 | |
| 2 | APP007 | Capcut | EDITING | CHN | support@capcut.com | invalid_date | 800000000 | Valid | 600000000 | INVALID | . | Y | 800,000,000 | 2300000000 |
| 3 | APP008 | Spotify | MUSIC | EUROPE | spotify.com | 2008-10-07 | 700000000 | Invalid | 650000000 | INVALID | 07OCT2008 | 700,000,000 | 3000000000 | |
| 4 | APP001 | MESSAGING | IND | support@whatsapp.com | 2009-01-15 | 2500000000 | Valid | 2000000000 | INVALID | 15JAN2009 | 2,500,000,000 | 5500000000 | ||
| 5 | APP005 | Telegram | MESSAGING | IND | help@telegram.org | 2026-15-01 | 900000000 | Valid | 850000000 | INVALID | . | Y | 900,000,000 | 6400000000 |
| 6 | APP012 | Null | GAMING | JPN | help@gaming.com | 2020-04-20 | 650000000 | Valid | 250000000 | INVALID | 20APR2020 | 650,000,000 | 7050000000 | |
| 7 | APP006 | Snapchat | SOCIAL | UK | support@snapchat.com | 2011-09-16 | . | Valid | 700000000 | INVALID | 16SEP2011 | Y | . | 7050000000 |
| 8 | APP002 | SOCIAL | USA | supportfacebook.com | 2004-02-04 | 3000000000 | Valid | 2500000000 | INVALID | 04FEB2004 | 3,000,000,000 | 10050000000 | ||
| 9 | APP004 | UNKNOWN | USA | support@instagram | 2010-10-06 | 2000000000 | . | 1700000000 | INVALID | 06OCT2010 | Y | 2,000,000,000 | 12050000000 | |
| 10 | APP009 | Chatgpt | AI | USA | support@openai.com | 2022-11-30 | 900000000 | Valid | 500000000 | INVALID | 30NOV2022 | 900,000,000 | 12950000000 | |
| 11 | APP010 | Temu | SHOPPING | USA | support@temu.com | 2022-09-01 | 1200000000 | Valid | 450000000 | INVALID | 01SEP2022 | 1,200,000,000 | 14150000000 | |
| 12 | APP011 | Threads | SOCIAL | USA | contact@threads.com | 2023-07-05 | 750000000 | Valid | 300000000 | INVALID | 05JUL2023 | 750,000,000 | 14900000000 | |
| 13 | APP013 | Zoom | BUSINESS | USA | zoom@@zoom.com | 2013-01-21 | 1000000000 | Valid | 400000000 | INVALID | 21JAN2013 | 1,000,000,000 | 15900000000 | |
| 14 | APP014 | Netflix | ENTERTAINMENT | USA | support@netflix.com | 2012-04-10 | 1100000000 | Valid | 350000000 | INVALID | 10APR2012 | 1,100,000,000 | 17000000000 | |
| 15 | APP015 | Uber | TRAVEL | USA | support@uber.com | 2011-03-11 | 950000000 | Valid | 600000000 | INVALID | 11MAR2011 | 950,000,000 | 17950000000 |
7.R Raw Dataset
library(tibble)
apps_raw <- tribble(
~app_id, ~app_name, ~category, ~country, ~downloads, ~rating, ~release_dt_raw, ~support_email, ~active_users,
"APP001","WhatsApp", "Messaging", "IND", 2500000000, 4.8, "2009-01-15", "support@whatsapp.com", 2000000000,
"APP002","facebook", "Social", "usa", 3000000000, 4.7, "2004-02-04", "supportfacebook.com", 2500000000,
"APP002","facebook", "Social", "USA", 3000000000, 4.7, "2004-02-04", "supportfacebook.com", 2500000000,
"APP003"," TikTok ", "Entertainment", "CHN", -1500000000, 4.9, "2016-09-15", "help@tiktok.com", 1800000000,
"APP004","Instagram", "NULL", "USA", 2000000000, 5.8, "2010-10-06", "support@instagram", 1700000000,
"APP005","Telegram", "Messaging", "INDIA", 900000000, 4.6, "2026-15-01", "help@telegram.org", 850000000,
"APP006","Snapchat", "Social", "UK", NA, 4.2, "2011-09-16", "support@snapchat.com", 700000000,
"APP007","CapCut", "editing", "chn", 800000000, 4.4, "invalid_date", "support@capcut.com", 600000000,
"APP008","Spotify", "Music", "EUROPE", 700000000, -2.0, "2008-10-07", "spotify.com", 650000000,
"APP009","ChatGPT", "AI", "USA", 900000000, 4.9, "2022-11-30", "support@openai.com", 500000000,
"APP010"," Temu ", "Shopping", "UsA", 1200000000, 4.5, "2022-09-01", "support@temu.com", 450000000,
"APP011","Threads", "social", "USA", 750000000, 4.3, "2023-07-05", "contact@threads.com", 300000000,
"APP012","NULL", "Gaming", "JPN", 650000000, 4.1, "2020-04-20", "help@gaming.com", 250000000,
"APP013","Zoom", "Business", "USA", 1000000000, 4.7, "2013-01-21", "zoom@@zoom.com", 400000000,
"APP014","Netflix", "Entertainment", "US", 1100000000, 4.8, "2012-04-10", "support@netflix.com", 350000000,
"APP015","Uber", "Travel", "USA", 950000000, 4.4, "2011-03-11", "support@uber.com", 600000000,
"APP016"," Canva", "Productivity", "Aus", 500000000, 4.7, "2013-08-19", "help@canva.com", 300000000,
"APP017","Shein", "Shopping", "china", 1300000000, 4.2, "2015-11-30", "support@shein", 800000000,
"APP018","Discord", "Communication", "USA ", 600000000, 4.5, "", "support@discord.com", 250000000,
"APP019","Spotify ", "music", "EU", 700000000, 4.3, "2008/10/07", "music@spotify.com", 650000000,
"APP020","Pinterest", "Social", "usa", 550000000, 6.2, "2010-03-10", "contact@pinterest.com", 450000000
)
OUTPUT:
|
app_id |
app_name |
category |
country |
downloads |
rating |
release_dt_raw |
support_email |
active_users |
|
APP001 |
WhatsApp |
Messaging |
IND |
2500000000 |
4.8 |
2009-01-15 |
support@whatsapp.com |
2000000000 |
|
APP002 |
facebook |
Social |
usa |
3000000000 |
4.7 |
2004-02-04 |
supportfacebook.com |
2500000000 |
|
APP002 |
facebook |
Social |
USA |
3000000000 |
4.7 |
2004-02-04 |
supportfacebook.com |
2500000000 |
|
APP003 |
TikTok |
Entertainment |
CHN |
-1500000000 |
4.9 |
2016-09-15 |
help@tiktok.com |
1800000000 |
|
APP004 |
Instagram |
NULL |
USA |
2000000000 |
5.8 |
2010-10-06 |
support@instagram |
1700000000 |
|
APP005 |
Telegram |
Messaging |
INDIA |
900000000 |
4.6 |
2026-15-01 |
help@telegram.org |
850000000 |
|
APP006 |
Snapchat |
Social |
UK |
4.2 |
2011-09-16 |
support@snapchat.com |
700000000 |
|
|
APP007 |
CapCut |
editing |
chn |
800000000 |
4.4 |
invalid_date |
support@capcut.com |
600000000 |
|
APP008 |
Spotify |
Music |
EUROPE |
700000000 |
-2 |
2008-10-07 |
spotify.com |
650000000 |
|
APP009 |
ChatGPT |
AI |
USA |
900000000 |
4.9 |
2022-11-30 |
support@openai.com |
500000000 |
|
APP010 |
Temu |
Shopping |
UsA |
1200000000 |
4.5 |
2022-09-01 |
support@temu.com |
450000000 |
|
APP011 |
Threads |
social |
USA |
750000000 |
4.3 |
2023-07-05 |
contact@threads.com |
300000000 |
|
APP012 |
NULL |
Gaming |
JPN |
650000000 |
4.1 |
2020-04-20 |
help@gaming.com |
250000000 |
|
APP013 |
Zoom |
Business |
USA |
1000000000 |
4.7 |
2013-01-21 |
zoom@@zoom.com |
400000000 |
|
APP014 |
Netflix |
Entertainment |
US |
1100000000 |
4.8 |
2012-04-10 |
support@netflix.com |
350000000 |
|
APP015 |
Uber |
Travel |
USA |
950000000 |
4.4 |
2011-03-11 |
support@uber.com |
600000000 |
|
APP016 |
Canva |
Productivity |
Aus |
500000000 |
4.7 |
2013-08-19 |
help@canva.com |
300000000 |
|
APP017 |
Shein |
Shopping |
china |
1300000000 |
4.2 |
2015-11-30 |
support@shein |
800000000 |
|
APP018 |
Discord |
Communication |
USA |
600000000 |
4.5 |
support@discord.com |
250000000 |
|
|
APP019 |
Spotify |
music |
EU |
700000000 |
4.3 |
2008/10/07 |
music@spotify.com |
650000000 |
|
APP020 |
Pinterest |
Social |
usa |
550000000 |
6.2 |
2010-03-10 |
contact@pinterest.com |
450000000 |
8.R Equivalent Cleaning Layer
library(tidyverse)
library(lubridate)
library(janitor)
options(scipen = 999)
apps_clean <-
apps_raw %>%
clean_names() %>%
mutate(
app_id=str_to_title(str_trim(app_id)),
app_name=str_to_title(str_trim(app_name)),
category=case_when(category=="NULL" ~ "UNKNOWN",
TRUE ~ category),
downloads=abs(downloads),
rating=if_else(rating>5,NA_real_,rating),
country=str_to_upper(country),
release_date = suppressWarnings(parse_date_time(
release_dt_raw,orders = c("ymd","dmy"))),
email_flag=if_else(grepl("@",support_email),
"VALID","INVALID")
)%>%
distinct(app_id,.keep_all = TRUE)
|
app_id |
app_name |
category |
country |
downloads |
rating |
release_dt_raw |
support_email |
active_users |
release_date |
email_flag |
|
App001 |
Whatsapp |
Messaging |
IND |
2500000000 |
4.8 |
2009-01-15 |
support@whatsapp.com |
2000000000 |
2009-01-15 00:00:00 UTC |
VALID |
|
App002 |
Facebook |
Social |
USA |
3000000000 |
4.7 |
2004-02-04 |
supportfacebook.com |
2500000000 |
2004-02-04 00:00:00 UTC |
INVALID |
|
App003 |
Tiktok |
Entertainment |
CHN |
1500000000 |
4.9 |
2016-09-15 |
help@tiktok.com |
1800000000 |
2016-09-15 00:00:00 UTC |
VALID |
|
App004 |
Instagram |
UNKNOWN |
USA |
2000000000 |
2010-10-06 |
support@instagram |
1700000000 |
2010-10-06 00:00:00 UTC |
VALID |
|
|
App005 |
Telegram |
Messaging |
INDIA |
900000000 |
4.6 |
2026-15-01 |
help@telegram.org |
850000000 |
VALID |
|
|
App006 |
Snapchat |
Social |
UK |
4.2 |
2011-09-16 |
support@snapchat.com |
700000000 |
2011-09-16 00:00:00 UTC |
VALID |
|
|
App007 |
Capcut |
editing |
CHN |
800000000 |
4.4 |
invalid_date |
support@capcut.com |
600000000 |
VALID |
|
|
App008 |
Spotify |
Music |
EUROPE |
700000000 |
-2 |
2008-10-07 |
spotify.com |
650000000 |
2008-10-07 00:00:00 UTC |
INVALID |
|
App009 |
Chatgpt |
AI |
USA |
900000000 |
4.9 |
2022-11-30 |
support@openai.com |
500000000 |
2022-11-30 00:00:00 UTC |
VALID |
|
App010 |
Temu |
Shopping |
USA |
1200000000 |
4.5 |
2022-09-01 |
support@temu.com |
450000000 |
2022-09-01 00:00:00 UTC |
VALID |
|
App011 |
Threads |
social |
USA |
750000000 |
4.3 |
2023-07-05 |
contact@threads.com |
300000000 |
2023-07-05 00:00:00 UTC |
VALID |
|
App012 |
Null |
Gaming |
JPN |
650000000 |
4.1 |
2020-04-20 |
help@gaming.com |
250000000 |
2020-04-20 00:00:00 UTC |
VALID |
|
App013 |
Zoom |
Business |
USA |
1000000000 |
4.7 |
2013-01-21 |
zoom@@zoom.com |
400000000 |
2013-01-21 00:00:00 UTC |
VALID |
|
App014 |
Netflix |
Entertainment |
US |
1100000000 |
4.8 |
2012-04-10 |
support@netflix.com |
350000000 |
2012-04-10 00:00:00 UTC |
VALID |
|
App015 |
Uber |
Travel |
USA |
950000000 |
4.4 |
2011-03-11 |
support@uber.com |
600000000 |
2011-03-11 00:00:00 UTC |
VALID |
|
App016 |
Canva |
Productivity |
AUS |
500000000 |
4.7 |
2013-08-19 |
help@canva.com |
300000000 |
2013-08-19 00:00:00 UTC |
VALID |
|
App017 |
Shein |
Shopping |
CHINA |
1300000000 |
4.2 |
2015-11-30 |
support@shein |
800000000 |
2015-11-30 00:00:00 UTC |
VALID |
|
App018 |
Discord |
Communication |
USA |
600000000 |
4.5 |
support@discord.com |
250000000 |
VALID |
||
|
App019 |
Spotify |
music |
EU |
700000000 |
4.3 |
2008/10/07 |
music@spotify.com |
650000000 |
2008-10-07 00:00:00 UTC |
VALID |
|
App020 |
Pinterest |
Social |
USA |
550000000 |
2010-03-10 |
contact@pinterest.com |
450000000 |
2010-03-10 00:00:00 UTC |
VALID |
SAS vs R Transformation Comparison
|
SAS |
R |
|
PROPCASE |
str_to_title |
|
STRIP |
str_trim |
|
TRANWRD |
str_replace_all |
|
COALESCEC |
coalesce |
|
IF THEN
ELSE |
if_else |
|
SELECT
WHEN |
case_when |
|
PROC
SQL |
dplyr
summarise |
|
PROC
SORT NODUPKEY |
distinct |
Enterprise Validation and
Compliance
Clinical
environments require:
- SDTM traceability
- ADaM reproducibility
- Independent QC
- Audit trails
- Metadata governance
- Controlled terminology
Missing
numeric values in SAS are dangerous.
Example:
if age<18 then pediatric='Y';
If AGE is
missing:
. < 18 evaluates TRUE
This
could classify missing-age patients as pediatric subjects.
That
single issue can invalidate regulatory submissions.
20 Data Cleaning Best
Practices
- Validate before
transformation.
- Standardize metadata.
- Maintain audit trails.
- Never overwrite source data.
- Use controlled terminology.
- Validate ranges.
- Standardize dates.
- Deduplicate early.
- Version control macros.
- Separate QC programming.
- Use defensive programming.
- Track lineage.
- Automate validations.
- Use reusable formats.
- Document assumptions.
- Maintain code reviews.
- Use parameterized macros.
- Store validation logs.
- Protect production
libraries.
- Reproduce outputs
consistently.
Business Logic Behind
Cleaning
Missing
values are rarely random.
A missing
patient age may indicate failed enrollment collection. A negative billing
amount may represent a reversed transaction. Invalid dates may reflect system
migration issues.
Standardization
ensures:
- age groups become accurate
- AI models receive valid
inputs
- dashboards remain
trustworthy
- forecasts remain
reproducible
Correcting
"india" and "IND" into "IND" prevents duplicate
regional reporting.
Normalizing
text improves joins.
Date
imputation prevents timeline fragmentation.
Cleaning
is not cosmetic.
It is
analytical risk management.
20 One-Line Insights
- Dirty data creates expensive
business mistakes.
- Validation logic beats visual
inspection.
- Standardized variables
improve reproducibility.
- Missing values deserve
investigation.
- Duplicate records distort
trends.
- Metadata drives consistency.
- Defensive programming saves
projects.
- Audit trails build trust.
- Reusable macros reduce
errors.
- Controlled terminology
improves reporting.
- Data lineage matters.
- Automation reduces risk.
- SQL excels at aggregation.
- DATA Step excels at row
logic.
- Formats simplify business
rules.
- Validation is continuous.
- Governance protects
analytics.
- Documentation prevents
confusion.
- Traceability matters.
- Quality data creates quality
decisions.
SAS vs R Strength
Comparison
|
Feature |
SAS |
R |
|
Auditability |
Excellent |
Moderate |
|
Regulatory
Use |
Excellent |
Growing |
|
Scalability |
Excellent |
Excellent |
|
Visualization |
Good |
Excellent |
|
Flexibility |
Moderate |
Excellent |
|
Traceability |
Excellent |
Moderate |
|
Statistical
Ecosystem |
Excellent |
Excellent |
SAS
dominates heavily regulated industries such as clinical research, banking, and
insurance due to traceability and compliance support.
R
dominates exploratory analytics and advanced modeling because of its
flexibility and package ecosystem.
Together
they provide an ideal enterprise cleaning architecture.
Conclusion
Modern
analytics platforms consume billions of records every day. Whether the source
is a clinical trial database, an insurance claims warehouse, a banking
transaction platform, or a global mobile application marketplace, poor data
quality spreads silently through every downstream process.
A
duplicate identifier can inflate revenue forecasts. An invalid date can destroy
longitudinal analysis. Missing demographic information can bias AI predictions.
Corrupted categorical values can split populations into false segments.
The
world's most downloaded applications generate extraordinary amounts of
behavioral and operational data. Turning that raw information into trusted
intelligence requires disciplined engineering processes rather than ad hoc
fixes.
SAS
provides industrial-strength governance, validation, lineage tracking, and
regulatory traceability. R provides unmatched flexibility, rapid
experimentation, and advanced analytical capabilities.
Together
they form a production-grade ecosystem capable of supporting:
- executive dashboards,
- AI pipelines,
- regulatory submissions,
- statistical reporting,
- operational intelligence,
- and enterprise
decision-making.
Data
cleaning is not a preprocessing task.
It is the
foundation of every trustworthy analytical conclusion.
Interview Questions
1. Why is PROC SORT NODUPKEY preferred for
deduplication?
Because
it removes duplicate business keys while preserving one representative
observation.
2. Why are missing numeric values dangerous in SAS?
Because
SAS treats missing numeric values as lower than valid numbers.
3. When should PROC SQL be preferred over DATA
Step?
For
joins, aggregations, and summarization.
4. When should DATA Step be preferred?
For
row-by-row transformations and complex derivations.
5. How would you validate email fields?
Using
VERIFY(), INDEX(), regular expressions, or pattern validation rules.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
About the Author:
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. Here we learn about APP 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
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Comments
Post a Comment