260.COMPARING MOBILE SPECIFICATIONS & SALES IN INDIA USING PROC PRINT | PROC SORT | PROC MEANS | PROC FREQ | PROC REPORT | PROC TRANSPOSE | PROC SQL | SAS MACROS

COMPARING MOBILE SPECIFICATIONS & SALES IN INDIA USING PROC PRINT | PROC SORT | PROC MEANS | PROC FREQ | PROC REPORT | PROC TRANSPOSE | PROC SQL | SAS MACROS

 /*Compare various mobiles in India using multiple SAS techniques*/

STEP 1: Creating the MOBILES dataset

options nocenter;

data mobiles;

    length Mobile_ID 8 Brand $20 Model $30 OS $15 Storage_GB 8 RAM_GB 8 

           Camera_MP 8 Battery_mAh 8 Price_INR 8 Launch_Year 8;

    infile datalines dlm=',';

    input Mobile_ID Brand $ Model $ OS $ Storage_GB RAM_GB Camera_MP Battery_mAh Price_INR Launch_Year;

    datalines;

1,Samsung,GalaxyS23,Android,256,8,50,4700,79999,2023

2,Apple,iPhone14,iOS,128,6,48,3279,79999,2022

3,Xiaomi,Mi13Pro,Android,256,12,50,4820,59999,2023

4,OnePlus,OnePlus11,Android,256,16,50,5000,56999,2023

5,Vivo,X90Pro,Android,256,12,50,4870,62999,2023

6,Oppo,FindX6,Android,256,12,50,4820,64999,2023

7,Realme,GTNeo5,Android,256,12,50,5000,38999,2023

8,Motorola,Edge40,Android,256,8,50,4400,29999,2023

9,Nothing,Phone1,Android,128,8,50,4500,31999,2022

10,Poco,F5Pro,Android,256,12,64,5160,39999,2023

11,Apple,iPhone15,iOS,256,8,48,3279,89999,2023

12,Samsung,GalaxyZFlip5,Android,256,8,12,3700,99999,2023

13,Apple,iPhone13,iOS,128,4,12,3227,58999,2021

14,OnePlus,OnePlusNord3,Android,256,12,50,5000,33999,2023

15,Vivo,V27Pro,Android,256,8,50,4600,37999,2023

16,Oppo,Reno10Pro,Android,256,12,64,4600,39999,2023

17,Realme,11ProPlus,Android,256,12,200,5000,29999,2023

18,Motorola,MotoG73,Android,128,8,50,5000,18999,2023

19,Xiaomi,RedmiNote12,Android,128,6,48,5000,16999,2023

20,Nokia,X30,Android,256,8,50,4200,36999,2023

21,Samsung,GalaxyA54,Android,128,8,50,5000,38999,2023

22,Apple,iPhoneSE3,iOS,128,4,12,2018,42999,2022

23,Xiaomi,RedmiK60,Android,256,12,64,5500,45999,2023

24,OnePlus,OnePlus10T,Android,256,16,50,4800,49999,2022

25,Vivo,Y100,Android,128,8,64,4500,24999,2023

;

run;

proc print;run;

Output:

ObsMobile_IDBrandModelOSStorage_GBRAM_GBCamera_MPBattery_mAhPrice_INRLaunch_Year
11SamsungGalaxyS23Android2568504700799992023
22AppleiPhone14iOS1286483279799992022
33XiaomiMi13ProAndroid25612504820599992023
44OnePlusOnePlus11Android25616505000569992023
55VivoX90ProAndroid25612504870629992023
66OppoFindX6Android25612504820649992023
77RealmeGTNeo5Android25612505000389992023
88MotorolaEdge40Android2568504400299992023
99NothingPhone1Android1288504500319992022
1010PocoF5ProAndroid25612645160399992023
1111AppleiPhone15iOS2568483279899992023
1212SamsungGalaxyZFlip5Android2568123700999992023
1313AppleiPhone13iOS1284123227589992021
1414OnePlusOnePlusNord3Android25612505000339992023
1515VivoV27ProAndroid2568504600379992023
1616OppoReno10ProAndroid25612644600399992023
1717Realme11ProPlusAndroid256122005000299992023
1818MotorolaMotoG73Android1288505000189992023
1919XiaomiRedmiNote12Android1286485000169992023
2020NokiaX30Android2568504200369992023
2121SamsungGalaxyA54Android1288505000389992023
2222AppleiPhoneSE3iOS1284122018429992022
2323XiaomiRedmiK60Android25612645500459992023
2424OnePlusOnePlus10TAndroid25616504800499992022
2525VivoY100Android1288644500249992023


STEP 2: Creating the SALES dataset

data sales;

    length Sale_ID 8 Mobile_ID 8 Units_Sold 8 Region $15 Quarter $2;

    infile datalines dlm=',';

    input Sale_ID Mobile_ID Units_Sold Region $ Quarter $;

    datalines;

1,1,5000,North,Q1

2,2,4500,North,Q1

3,3,6000,West,Q1

4,4,5500,South,Q1

5,5,4800,East,Q1

6,6,3000,West,Q1

7,7,4200,North,Q1

8,8,2500,East,Q1

9,9,3200,West,Q1

10,10,2800,South,Q1

11,11,4900,North,Q2

12,12,1500,West,Q2

13,13,5200,South,Q2

14,14,3700,East,Q2

15,15,3900,North,Q2

16,16,4100,West,Q2

17,17,3300,South,Q2

18,18,3700,East,Q2

19,19,4200,North,Q2

20,20,2500,South,Q2

21,21,3800,North,Q3

22,22,3000,West,Q3

23,23,2100,South,Q3

24,24,2700,East,Q3

25,25,2300,North,Q3

;

run;

proc print;run;

Output:

ObsSale_IDMobile_IDUnits_SoldRegionQuarter
1115000NorthQ1
2224500NorthQ1
3336000WestQ1
4445500SouthQ1
5554800EastQ1
6663000WestQ1
7774200NorthQ1
8882500EastQ1
9993200WestQ1
1010102800SouthQ1
1111114900NorthQ2
1212121500WestQ2
1313135200SouthQ2
1414143700EastQ2
1515153900NorthQ2
1616164100WestQ2
1717173300SouthQ2
1818183700EastQ2
1919194200NorthQ2
2020202500SouthQ2
2121213800NorthQ3
2222223000WestQ3
2323232100SouthQ3
2424242700EastQ3
2525252300NorthQ3


STEP 3: PROC PRINT — Display datasets

proc print data=mobiles;

    title "List of Mobiles in India - Specifications";

run;

Output:

List of Mobiles in India - Specifications

ObsMobile_IDBrandModelOSStorage_GBRAM_GBCamera_MPBattery_mAhPrice_INRLaunch_Year
11SamsungGalaxyS23Android2568504700799992023
22AppleiPhone14iOS1286483279799992022
33XiaomiMi13ProAndroid25612504820599992023
44OnePlusOnePlus11Android25616505000569992023
55VivoX90ProAndroid25612504870629992023
66OppoFindX6Android25612504820649992023
77RealmeGTNeo5Android25612505000389992023
88MotorolaEdge40Android2568504400299992023
99NothingPhone1Android1288504500319992022
1010PocoF5ProAndroid25612645160399992023
proc print data=sales;

    title "Mobile Sales Data in India";

run;

Output:

Mobile Sales Data in India

ObsSale_IDMobile_IDUnits_SoldRegionQuarter
1115000NorthQ1
2224500NorthQ1
3336000WestQ1
4445500SouthQ1
5554800EastQ1
6663000WestQ1
7774200NorthQ1
8882500EastQ1
9993200WestQ1
1010102800SouthQ1

STEP 4: PROC SORT — Sort mobiles by price (descending)

proc sort data=mobiles out=mobiles_sorted;

    by descending Price_INR;

run;

title "Mobiles Sorted by Price (Highest First)";

proc print data=mobiles_sorted;

run;

 Output:

Mobiles Sorted by Price (Highest First)

ObsMobile_IDBrandModelOSStorage_GBRAM_GBCamera_MPBattery_mAhPrice_INRLaunch_Year
112SamsungGalaxyZFlip5Android2568123700999992023
211AppleiPhone15iOS2568483279899992023
31SamsungGalaxyS23Android2568504700799992023
42AppleiPhone14iOS1286483279799992022
56OppoFindX6Android25612504820649992023
65VivoX90ProAndroid25612504870629992023
73XiaomiMi13ProAndroid25612504820599992023
813AppleiPhone13iOS1284123227589992021
94OnePlusOnePlus11Android25616505000569992023
1024OnePlusOnePlus10TAndroid25616504800499992022
1123XiaomiRedmiK60Android25612645500459992023
1222AppleiPhoneSE3iOS1284122018429992022
1310PocoF5ProAndroid25612645160399992023
1416OppoReno10ProAndroid25612644600399992023
157RealmeGTNeo5Android25612505000389992023
1621SamsungGalaxyA54Android1288505000389992023
1715VivoV27ProAndroid2568504600379992023
1820NokiaX30Android2568504200369992023
1914OnePlusOnePlusNord3Android25612505000339992023
209NothingPhone1Android1288504500319992022
218MotorolaEdge40Android2568504400299992023
2217Realme11ProPlusAndroid256122005000299992023
2325VivoY100Android1288644500249992023
2418MotorolaMotoG73Android1288505000189992023
2519XiaomiRedmiNote12Android1286485000169992023

STEP 5: PROC MEANS — Price and battery statistics

proc means data=mobiles mean min max;

    var Price_INR Battery_mAh;

run;

Output:

The MEANS Procedure

VariableMeanMinimumMaximum
Price_INR
Battery_mAh
48519.00
4478.92
16999.00
2018.00
99999.00
5500.00-0

STEP 6: PROC FREQ — OS type count

proc freq data=mobiles;

    tables OS;

run;

Output:

The FREQ Procedure

OSFrequencyPercentCumulative
Frequency
Cumulative
Percent
Android2184.002184.00
iOS416.0025100.00

STEP 7: PROC REPORT — Brand-wise price and storage summary

proc report data=mobiles nowd;

    column Brand Price_INR Storage_GB;

    define Brand / group;

    define Price_INR / mean;

    define Storage_GB / mean;

run;

Output:

BrandPrice_INRStorage_GB
Apple67999160
Motorola24499192
Nokia36999256
Nothing31999128
OnePlus46999256
Oppo52499256
Poco39999256
Realme34499256
Samsung72999213.33333
Vivo41999213.33333
Xiaomi40999213.33333

STEP 8: PROC TRANSPOSE — Reshape data for Year-wise analysis

proc transpose data=mobiles out=mobiles_transposed prefix=Mobile_;

    by Launch_Year;

    var Price_INR;

run;

proc print data=mobiles_transposed;run;

Output:

ObsLaunch_Year_NAME_Mobile_1Mobile_2Mobile_3Mobile_4Mobile_5Mobile_6Mobile_7Mobile_8
12023Price_INR79999.......
22022Price_INR79999.......
32023Price_INR599995699962999649993899929999..
42022Price_INR31999.......
52023Price_INR399998999999999.....
62021Price_INR58999.......
72023Price_INR3399937999399992999918999169993699938999
82022Price_INR42999.......
92023Price_INR45999.......
102022Price_INR49999.......
112023Price_INR24999.......


STEP 9: PROC SQL — Join mobiles & sales for revenue

proc sql;

    create table mobile_revenue as

    select m.Brand, m.Model, m.Price_INR, s.Units_Sold,

           (m.Price_INR * s.Units_Sold) as Revenue

    from mobiles m

    join sales s

    on m.Mobile_ID = s.Mobile_ID;

quit;


title "Mobile Revenue Calculation";

proc print data=mobile_revenue;

run;

Output:

Mobile Revenue Calculation

ObsBrandModelPrice_INRUnits_SoldRevenue
1SamsungGalaxyS23799995000399995000
2AppleiPhone14799994500359995500
3XiaomiMi13Pro599996000359994000
4OnePlusOnePlus11569995500313494500
5VivoX90Pro629994800302395200
6OppoFindX6649993000194997000
7RealmeGTNeo5389994200163795800
8MotorolaEdge4029999250074997500
9NothingPhone1319993200102396800
10PocoF5Pro399992800111997200
11AppleiPhone15899994900440995100
12SamsungGalaxyZFlip5999991500149998500
13AppleiPhone13589995200306794800
14OnePlusOnePlusNord3339993700125796300
15VivoV27Pro379993900148196100
16OppoReno10Pro399994100163995900
17Realme11ProPlus29999330098996700
18MotorolaMotoG7318999370070296300
19XiaomiRedmiNote1216999420071395800
20NokiaX3036999250092497500
21SamsungGalaxyA54389993800148196200
22AppleiPhoneSE3429993000128997000
23XiaomiRedmiK6045999210096597900
24OnePlusOnePlus10T499992700134997300
25VivoY10024999230057497700

STEP 10: SAS Macro — Top Selling Mobiles by Units

%macro top_sellers(threshold);

    proc sql;

        select Brand, Model, Units_Sold

        from mobile_revenue

        where Units_Sold > &threshold

        order by Units_Sold desc;

    quit;

%mend;


%top_sellers(4000);

Output:

BrandModelUnits_Sold
XiaomiMi13Pro6000
OnePlusOnePlus115500
AppleiPhone135200
SamsungGalaxyS235000
AppleiPhone154900
VivoX90Pro4800
AppleiPhone144500
RealmeGTNeo54200
XiaomiRedmiNote124200
OppoReno10Pro4100





To Visit My Previous Online Streaming Flatform Dataset:Click Here
To Visit My Previous Statistical Evaluation Of Clinical Trials:Click Here
To Visit My Previous Unlocking Retail Insights Dataset:Click Here
To Visit My Previous Sas Interview Questions-1:Click Here





--->PLEASE FOLLOW OUR BLOG FOR MORE INFORMATION.
--->PLEASE DO COMMENTS AND SHARE OUR BLOG.

PLEASE FOLLOW OUR TELEGRAM CHANNEL CLICK HERE

PLEASE FOLLOW OUR FACEBOOK PAGE  CLICK HERE

PLEASE FOLLOW OUR INSTAGRAM PAGE CLICK HERE

Comments