255.SAS FEAST ON CHICKEN DATA: PROC FORMAT | PROC CONTENTS | PROC SORT | PROC PRINT | PROC FREQ | PROC MEANS | PROC UNIVARIATE | PROC SQL | PROC TRANSPOSE | PROC REPORT | PROC TABULATE | PROC SGPLOT | PROC EXPORT
- Get link
- X
- Other Apps
SAS FEAST ON CHICKEN DATA: PROC FORMAT | PROC CONTENTS | PROC SORT | PROC PRINT | PROC FREQ | PROC MEANS | PROC UNIVARIATE | PROC SQL | PROC TRANSPOSE | PROC REPORT | PROC TABULATE | PROC SGPLOT | PROC EXPORT
/*A dataset of chicken items in India*/
1) Create the dataset
options nocenter;
data chicken_india;
infile datalines dlm=',' dsd truncover;
length RecordID 8 Type $12 Breed $20 CutType $12 FeedType $15 Market $25 State $15 SellerType $12 ProcessingPlant $20 Cert $12;
format DateSold yymmdd10.;
input RecordID Type $ Breed $ CutType $ FeedType $ WeightKg PricePerKg DateSold : yymmdd10. Market $ State $ SellerType $ Vaccinated $ Organic $ Packaged $ ProcessingPlant $ Cert $ SalesQty;
datalines;
1,Broiler,Venky Broiler,Whole,Commercial,1.8,195,2025-06-02,Secunderabad,Telangana,Retail,Yes,No,No,PlantA,AGMARK,10
2,Layer,Desi Layer,Whole,Grain-fed,1.2,220,2025-06-03,Hyderabad,Telangana,Backyard,Yes,Yes,No,PlantB,NoCert,2
3,Country,Desi Country,Legs,Free-range,0.9,260,2025-06-05,Warangal,Telangana,Wholesale,Yes,Yes,No,PlantC,NoCert,20
4,Broiler,Silver Broiler,Breast,Commercial,0.7,250,2025-06-05,Vijayawada,Andhra Pradesh,Retail,Yes,No,Yes,PlantA,AGMARK,5
5,Free-range,Desi Free,Whole,Free-range,1.4,300,2025-06-06,Mumbai,Maharashtra,Wholesale,Yes,Yes,No,PlantD,ISO,50
6,Broiler,Venky Broiler,Wings,Commercial,0.4,185,2025-06-07,Pune,Maharashtra,Retail,Yes,No,No,PlantA,AGMARK,8
7,Layer,Commercial Layer,Breast,Grain-fed,0.6,210,2025-06-07,Chennai,Tamil Nadu,Supermarket,Yes,No,Yes,PlantE,FSSAI,12
8,Country,Desi Country,Whole,BackyardFeed,1.1,280,2025-06-08,Bengaluru,Karnataka,Backyard,Yes,Yes,No,PlantC,NoCert,1
9,Broiler,Silver Broiler,Legs,Commercial,1.0,230,2025-06-09,Secunderabad,Telangana,Retail,Yes,No,Yes,PlantA,AGMARK,6
10,Free-range,Desi Free,Breast,Free-range,0.8,320,2025-06-10,Hyderabad,Telangana,Supermarket,Yes,Yes,Yes,PlantD,ISO,4
11,Broiler,Venky Broiler,Whole,Commercial,1.5,200,2025-06-11,Visakhapatnam,Andhra Pradesh,Wholesale,Yes,No,No,PlantA,AGMARK,30
12,Country,Desi Country,Wings,BackyardFeed,0.5,270,2025-06-12,Vijayawada,Andhra Pradesh,Backyard,Yes,Yes,No,PlantC,NoCert,3
13,Layer,Commercial Layer,Legs,Grain-fed,0.9,205,2025-06-13,Lucknow,Uttar Pradesh,Wholesale,Yes,No,No,PlantE,FSSAI,40
14,Free-range,Desi Free,Wings,Free-range,0.3,350,2025-06-14,Kanpur,Uttar Pradesh,Retail,Yes,Yes,No,PlantD,ISO,2
15,Broiler,Silver Broiler,Breast,Commercial,0.95,240,2025-06-14,Patna,Bihar,Supermarket,Yes,No,Yes,PlantA,AGMARK,9
16,Broiler,Venky Broiler,Legs,Commercial,1.2,210,2025-06-15,Bhubaneswar,Odisha,Wholesale,Yes,No,No,PlantA,AGMARK,22
17,Country,Desi Country,Whole,BackyardFeed,1.6,290,2025-06-16,Ahmedabad,Gujarat,Backyard,Yes,Yes,No,PlantC,NoCert,1
18,Free-range,Desi Free,Legs,Free-range,1.3,310,2025-06-16,Surat,Gujarat,Retail,Yes,Yes,No,PlantD,ISO,7
19,Layer,Desi Layer,Wings,Grain-fed,0.45,215,2025-06-17,Indore,Madhya Pradesh,Wholesale,Yes,No,No,PlantE,FSSAI,35
20,Broiler,Silver Broiler,Whole,Commercial,2.1,190,2025-06-17,Bhopal,Madhya Pradesh,Retail,Yes,No,No,PlantA,AGMARK,11
21,Free-range,Desi Free,Breast,Free-range,0.75,340,2025-06-18,Jaipur,Rajasthan,Supermarket,Yes,Yes,Yes,PlantD,ISO,6
22,Country,Desi Country,Wings,BackyardFeed,0.6,275,2025-06-18,Udaipur,Rajasthan,Backyard,Yes,Yes,No,PlantC,NoCert,2
23,Broiler,Venky Broiler,Breast,Commercial,0.85,205,2025-06-19,Agra,Uttar Pradesh,Wholesale,Yes,No,No,PlantA,AGMARK,27
24,Layer,Commercial Layer,Whole,Grain-fed,1.05,200,2025-06-19,Varanasi,Uttar Pradesh,Retail,Yes,No,No,PlantE,FSSAI,4
25,Free-range,Desi Free,Wings,Free-range,0.55,330,2025-06-20,Shimla,Himachal Pradesh,Supermarket,Yes,Yes,No,PlantD,ISO,3
26,Broiler,Silver Broiler,Legs,Commercial,1.4,225,2025-06-20,Chandigarh,Chandigarh,Wholesale,Yes,No,No,PlantA,AGMARK,15
27,Country,Desi Country,Breast,BackyardFeed,1.9,295,2025-06-21,Dehradun,Uttrakhand,Backyard,Yes,Yes,No,PlantC,NoCert,1
28,Layer,Desi Layer,Legs,Grain-fed,0.4,210,2025-06-21,Noida,Uttar Pradesh,Supermarket,Yes,No,Yes,PlantE,FSSAI,5
29,Broiler,Venky Broiler,Whole,Commercial,1.7,198,2025-06-22,Ghaziabad,Uttar Pradesh,Retail,Yes,No,No,PlantA,AGMARK,13
30,Free-range,Desi Free,Breast,Free-range,0.95,315,2025-06-23,Kolkata,West Bengal,Wholesale,Yes,Yes,No,PlantD,ISO,18
31,Broiler,Silver Broiler,Wings,Commercial,0.35,190,2025-06-24,Asansol,West Bengal,Supermarket,Yes,No,Yes,PlantA,AGMARK,7
32,Country,Desi Country,Whole,BackyardFeed,2.0,305,2025-06-24,Patiala,Punjab,Backyard,Yes,Yes,No,PlantC,NoCert,1
33,Layer,Commercial Layer,Wings,Grain-fed,0.5,208,2025-06-25,Ludhiana,Punjab,Retail,Yes,No,No,PlantE,FSSAI,9
34,Free-range,Desi Free,Legs,Free-range,1.6,330,2025-06-25,Amritsar,Punjab,Wholesale,Yes,Yes,No,PlantD,ISO,20
35,Broiler,Venky Broiler,Breast,Commercial,1.1,215,2025-06-26,Raipur,Chhattisgarh,Retail,Yes,No,No,PlantA,AGMARK,14
36,Country,Desi Country,Breast,BackyardFeed,1.25,298,2025-06-26,Ranchi,Jharkhand,Backyard,Yes,Yes,No,PlantC,NoCert,2
;
run;
proc print;run;
Output:
Obs | RecordID | Type | Breed | CutType | FeedType | Market | State | SellerType | ProcessingPlant | Cert | DateSold | WeightKg | PricePerKg | Vaccinated | Organic | Packaged | SalesQty |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 1 | Broiler | Venky Broiler | Whole | Commercial | Secunderabad | Telangana | Retail | PlantA | AGMARK | 2025-06-02 | 1.80 | 195 | Yes | No | No | 10 |
2 | 2 | Layer | Desi Layer | Whole | Grain-fed | Hyderabad | Telangana | Backyard | PlantB | NoCert | 2025-06-03 | 1.20 | 220 | Yes | Yes | No | 2 |
3 | 3 | Country | Desi Country | Legs | Free-range | Warangal | Telangana | Wholesale | PlantC | NoCert | 2025-06-05 | 0.90 | 260 | Yes | Yes | No | 20 |
4 | 4 | Broiler | Silver Broiler | Breast | Commercial | Vijayawada | Andhra Pradesh | Retail | PlantA | AGMARK | 2025-06-05 | 0.70 | 250 | Yes | No | Yes | 5 |
5 | 5 | Free-range | Desi Free | Whole | Free-range | Mumbai | Maharashtra | Wholesale | PlantD | ISO | 2025-06-06 | 1.40 | 300 | Yes | Yes | No | 50 |
6 | 6 | Broiler | Venky Broiler | Wings | Commercial | Pune | Maharashtra | Retail | PlantA | AGMARK | 2025-06-07 | 0.40 | 185 | Yes | No | No | 8 |
7 | 7 | Layer | Commercial Layer | Breast | Grain-fed | Chennai | Tamil Nadu | Supermarket | PlantE | FSSAI | 2025-06-07 | 0.60 | 210 | Yes | No | Yes | 12 |
8 | 8 | Country | Desi Country | Whole | BackyardFeed | Bengaluru | Karnataka | Backyard | PlantC | NoCert | 2025-06-08 | 1.10 | 280 | Yes | Yes | No | 1 |
9 | 9 | Broiler | Silver Broiler | Legs | Commercial | Secunderabad | Telangana | Retail | PlantA | AGMARK | 2025-06-09 | 1.00 | 230 | Yes | No | Yes | 6 |
10 | 10 | Free-range | Desi Free | Breast | Free-range | Hyderabad | Telangana | Supermarket | PlantD | ISO | 2025-06-10 | 0.80 | 320 | Yes | Yes | Yes | 4 |
11 | 11 | Broiler | Venky Broiler | Whole | Commercial | Visakhapatnam | Andhra Pradesh | Wholesale | PlantA | AGMARK | 2025-06-11 | 1.50 | 200 | Yes | No | No | 30 |
12 | 12 | Country | Desi Country | Wings | BackyardFeed | Vijayawada | Andhra Pradesh | Backyard | PlantC | NoCert | 2025-06-12 | 0.50 | 270 | Yes | Yes | No | 3 |
13 | 13 | Layer | Commercial Layer | Legs | Grain-fed | Lucknow | Uttar Pradesh | Wholesale | PlantE | FSSAI | 2025-06-13 | 0.90 | 205 | Yes | No | No | 40 |
14 | 14 | Free-range | Desi Free | Wings | Free-range | Kanpur | Uttar Pradesh | Retail | PlantD | ISO | 2025-06-14 | 0.30 | 350 | Yes | Yes | No | 2 |
15 | 15 | Broiler | Silver Broiler | Breast | Commercial | Patna | Bihar | Supermarket | PlantA | AGMARK | 2025-06-14 | 0.95 | 240 | Yes | No | Yes | 9 |
16 | 16 | Broiler | Venky Broiler | Legs | Commercial | Bhubaneswar | Odisha | Wholesale | PlantA | AGMARK | 2025-06-15 | 1.20 | 210 | Yes | No | No | 22 |
17 | 17 | Country | Desi Country | Whole | BackyardFeed | Ahmedabad | Gujarat | Backyard | PlantC | NoCert | 2025-06-16 | 1.60 | 290 | Yes | Yes | No | 1 |
18 | 18 | Free-range | Desi Free | Legs | Free-range | Surat | Gujarat | Retail | PlantD | ISO | 2025-06-16 | 1.30 | 310 | Yes | Yes | No | 7 |
19 | 19 | Layer | Desi Layer | Wings | Grain-fed | Indore | Madhya Pradesh | Wholesale | PlantE | FSSAI | 2025-06-17 | 0.45 | 215 | Yes | No | No | 35 |
20 | 20 | Broiler | Silver Broiler | Whole | Commercial | Bhopal | Madhya Pradesh | Retail | PlantA | AGMARK | 2025-06-17 | 2.10 | 190 | Yes | No | No | 11 |
21 | 21 | Free-range | Desi Free | Breast | Free-range | Jaipur | Rajasthan | Supermarket | PlantD | ISO | 2025-06-18 | 0.75 | 340 | Yes | Yes | Yes | 6 |
22 | 22 | Country | Desi Country | Wings | BackyardFeed | Udaipur | Rajasthan | Backyard | PlantC | NoCert | 2025-06-18 | 0.60 | 275 | Yes | Yes | No | 2 |
23 | 23 | Broiler | Venky Broiler | Breast | Commercial | Agra | Uttar Pradesh | Wholesale | PlantA | AGMARK | 2025-06-19 | 0.85 | 205 | Yes | No | No | 27 |
24 | 24 | Layer | Commercial Layer | Whole | Grain-fed | Varanasi | Uttar Pradesh | Retail | PlantE | FSSAI | 2025-06-19 | 1.05 | 200 | Yes | No | No | 4 |
25 | 25 | Free-range | Desi Free | Wings | Free-range | Shimla | Himachal Prades | Supermarket | PlantD | ISO | 2025-06-20 | 0.55 | 330 | Yes | Yes | No | 3 |
26 | 26 | Broiler | Silver Broiler | Legs | Commercial | Chandigarh | Chandigarh | Wholesale | PlantA | AGMARK | 2025-06-20 | 1.40 | 225 | Yes | No | No | 15 |
27 | 27 | Country | Desi Country | Breast | BackyardFeed | Dehradun | Uttrakhand | Backyard | PlantC | NoCert | 2025-06-21 | 1.90 | 295 | Yes | Yes | No | 1 |
28 | 28 | Layer | Desi Layer | Legs | Grain-fed | Noida | Uttar Pradesh | Supermarket | PlantE | FSSAI | 2025-06-21 | 0.40 | 210 | Yes | No | Yes | 5 |
29 | 29 | Broiler | Venky Broiler | Whole | Commercial | Ghaziabad | Uttar Pradesh | Retail | PlantA | AGMARK | 2025-06-22 | 1.70 | 198 | Yes | No | No | 13 |
30 | 30 | Free-range | Desi Free | Breast | Free-range | Kolkata | West Bengal | Wholesale | PlantD | ISO | 2025-06-23 | 0.95 | 315 | Yes | Yes | No | 18 |
31 | 31 | Broiler | Silver Broiler | Wings | Commercial | Asansol | West Bengal | Supermarket | PlantA | AGMARK | 2025-06-24 | 0.35 | 190 | Yes | No | Yes | 7 |
32 | 32 | Country | Desi Country | Whole | BackyardFeed | Patiala | Punjab | Backyard | PlantC | NoCert | 2025-06-24 | 2.00 | 305 | Yes | Yes | No | 1 |
33 | 33 | Layer | Commercial Layer | Wings | Grain-fed | Ludhiana | Punjab | Retail | PlantE | FSSAI | 2025-06-25 | 0.50 | 208 | Yes | No | No | 9 |
34 | 34 | Free-range | Desi Free | Legs | Free-range | Amritsar | Punjab | Wholesale | PlantD | ISO | 2025-06-25 | 1.60 | 330 | Yes | Yes | No | 20 |
35 | 35 | Broiler | Venky Broiler | Breast | Commercial | Raipur | Chhattisgarh | Retail | PlantA | AGMARK | 2025-06-26 | 1.10 | 215 | Yes | No | No | 14 |
36 | 36 | Country | Desi Country | Breast | BackyardFeed | Ranchi | Jharkhand | Backyard | PlantC | NoCert | 2025-06-26 | 1.25 | 298 | Yes | Yes | No | 2 |
2) Useful formats and preparatory steps
proc format;
value $yesno 'Yes'='Yes'
'No'='No';
value $typefmt 'Broiler'='Broiler'
'Layer'='Layer'
'Country'='Country'
'Free-range'='Free-range';
run;
proc contents data=chicken_india varnum;
run;
Output:
The CONTENTS Procedure
Data Set Name | WORK.CHICKEN_INDIA | Observations | 36 |
---|---|---|---|
Member Type | DATA | Variables | 17 |
Engine | V9 | Indexes | 0 |
Created | 08/08/2025 18:51:53 | Observation Length | 208 |
Last Modified | 08/08/2025 18:51:53 | Deleted Observations | 0 |
Protection | Compressed | NO | |
Data Set Type | Sorted | NO | |
Label | |||
Data Representation | SOLARIS_X86_64, LINUX_X86_64, ALPHA_TRU64, LINUX_IA64 | ||
Encoding | utf-8 Unicode (UTF-8) |
Engine/Host Dependent Information | |
---|---|
Data Set Page Size | 131072 |
Number of Data Set Pages | 1 |
First Data Page | 1 |
Max Obs per Page | 629 |
Obs in First Data Page | 36 |
Number of Data Set Repairs | 0 |
Filename | /saswork/SAS_work7F7700001503_odaws01-apse1-2.oda.sas.com/SAS_workA48A00001503_odaws01-apse1-2.oda.sas.com/chicken_india.sas7bdat |
Release Created | 9.0401M8 |
Host Created | Linux |
Inode Number | 1082105 |
Access Permission | rw-r--r-- |
Owner Name | u63247146 |
File Size | 256KB |
File Size (bytes) | 262144 |
Variables in Creation Order | ||||
---|---|---|---|---|
# | Variable | Type | Len | Format |
1 | RecordID | Num | 8 | |
2 | Type | Char | 12 | |
3 | Breed | Char | 20 | |
4 | CutType | Char | 12 | |
5 | FeedType | Char | 15 | |
6 | Market | Char | 25 | |
7 | State | Char | 15 | |
8 | SellerType | Char | 12 | |
9 | ProcessingPlant | Char | 20 | |
10 | Cert | Char | 12 | |
11 | DateSold | Num | 8 | YYMMDD10. |
12 | WeightKg | Num | 8 | |
13 | PricePerKg | Num | 8 | |
14 | Vaccinated | Char | 8 | |
15 | Organic | Char | 8 | |
16 | Packaged | Char | 8 | |
17 | SalesQty | Num | 8 |
3) Basic exploration (printing & sorting)
purpose: PROC SORT orders data for joins, by-group processing, and clear reporting.
proc sort data=chicken_india out=chicken_sorted;
by State Type descending DateSold;
run;
purpose: PROC PRINT shows raw rows for quick inspection.
proc print data=chicken_sorted(obs=20);
title "First 20 records of chicken_sorted";
run;
First 20 records of chicken_sorted
Obs | RecordID | Type | Breed | CutType | FeedType | Market | State | SellerType | ProcessingPlant | Cert | DateSold | WeightKg | PricePerKg | Vaccinated | Organic | Packaged | SalesQty |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 11 | Broiler | Venky Broiler | Whole | Commercial | Visakhapatnam | Andhra Pradesh | Wholesale | PlantA | AGMARK | 2025-06-11 | 1.50 | 200 | Yes | No | No | 30 |
2 | 4 | Broiler | Silver Broiler | Breast | Commercial | Vijayawada | Andhra Pradesh | Retail | PlantA | AGMARK | 2025-06-05 | 0.70 | 250 | Yes | No | Yes | 5 |
3 | 12 | Country | Desi Country | Wings | BackyardFeed | Vijayawada | Andhra Pradesh | Backyard | PlantC | NoCert | 2025-06-12 | 0.50 | 270 | Yes | Yes | No | 3 |
4 | 15 | Broiler | Silver Broiler | Breast | Commercial | Patna | Bihar | Supermarket | PlantA | AGMARK | 2025-06-14 | 0.95 | 240 | Yes | No | Yes | 9 |
5 | 26 | Broiler | Silver Broiler | Legs | Commercial | Chandigarh | Chandigarh | Wholesale | PlantA | AGMARK | 2025-06-20 | 1.40 | 225 | Yes | No | No | 15 |
6 | 35 | Broiler | Venky Broiler | Breast | Commercial | Raipur | Chhattisgarh | Retail | PlantA | AGMARK | 2025-06-26 | 1.10 | 215 | Yes | No | No | 14 |
7 | 17 | Country | Desi Country | Whole | BackyardFeed | Ahmedabad | Gujarat | Backyard | PlantC | NoCert | 2025-06-16 | 1.60 | 290 | Yes | Yes | No | 1 |
8 | 18 | Free-range | Desi Free | Legs | Free-range | Surat | Gujarat | Retail | PlantD | ISO | 2025-06-16 | 1.30 | 310 | Yes | Yes | No | 7 |
9 | 25 | Free-range | Desi Free | Wings | Free-range | Shimla | Himachal Prades | Supermarket | PlantD | ISO | 2025-06-20 | 0.55 | 330 | Yes | Yes | No | 3 |
10 | 36 | Country | Desi Country | Breast | BackyardFeed | Ranchi | Jharkhand | Backyard | PlantC | NoCert | 2025-06-26 | 1.25 | 298 | Yes | Yes | No | 2 |
11 | 8 | Country | Desi Country | Whole | BackyardFeed | Bengaluru | Karnataka | Backyard | PlantC | NoCert | 2025-06-08 | 1.10 | 280 | Yes | Yes | No | 1 |
12 | 20 | Broiler | Silver Broiler | Whole | Commercial | Bhopal | Madhya Pradesh | Retail | PlantA | AGMARK | 2025-06-17 | 2.10 | 190 | Yes | No | No | 11 |
13 | 19 | Layer | Desi Layer | Wings | Grain-fed | Indore | Madhya Pradesh | Wholesale | PlantE | FSSAI | 2025-06-17 | 0.45 | 215 | Yes | No | No | 35 |
14 | 6 | Broiler | Venky Broiler | Wings | Commercial | Pune | Maharashtra | Retail | PlantA | AGMARK | 2025-06-07 | 0.40 | 185 | Yes | No | No | 8 |
15 | 5 | Free-range | Desi Free | Whole | Free-range | Mumbai | Maharashtra | Wholesale | PlantD | ISO | 2025-06-06 | 1.40 | 300 | Yes | Yes | No | 50 |
16 | 16 | Broiler | Venky Broiler | Legs | Commercial | Bhubaneswar | Odisha | Wholesale | PlantA | AGMARK | 2025-06-15 | 1.20 | 210 | Yes | No | No | 22 |
17 | 32 | Country | Desi Country | Whole | BackyardFeed | Patiala | Punjab | Backyard | PlantC | NoCert | 2025-06-24 | 2.00 | 305 | Yes | Yes | No | 1 |
18 | 34 | Free-range | Desi Free | Legs | Free-range | Amritsar | Punjab | Wholesale | PlantD | ISO | 2025-06-25 | 1.60 | 330 | Yes | Yes | No | 20 |
19 | 33 | Layer | Commercial Layer | Wings | Grain-fed | Ludhiana | Punjab | Retail | PlantE | FSSAI | 2025-06-25 | 0.50 | 208 | Yes | No | No | 9 |
20 | 22 | Country | Desi Country | Wings | BackyardFeed | Udaipur | Rajasthan | Backyard | PlantC | NoCert | 2025-06-18 | 0.60 | 275 | Yes | Yes | No | 2 |
4) Frequency counts and cross-tabs
purpose: PROC FREQ shows counts and cross-tabulations for categorical exploration.
proc freq data=chicken_india;
tables State Type*CutType FeedType*Organic / nocum nopercent;
run;
Output:
The FREQ Procedure
State | Frequency |
---|---|
Andhra Pradesh | 3 |
Bihar | 1 |
Chandigarh | 1 |
Chhattisgarh | 1 |
Gujarat | 2 |
Himachal Prades | 1 |
Jharkhand | 1 |
Karnataka | 1 |
Madhya Pradesh | 2 |
Maharashtra | 2 |
Odisha | 1 |
Punjab | 3 |
Rajasthan | 2 |
Tamil Nadu | 1 |
Telangana | 5 |
Uttar Pradesh | 6 |
Uttrakhand | 1 |
West Bengal | 2 |
|
|
|
|
5) Summary statistics
purpose: PROC MEANS computes numeric summaries (mean, median, std, quartiles) often by groups.
proc means data=chicken_india n mean median min max std q1 q3;
var WeightKg PricePerKg SalesQty;
class Type;
run;
Output:
The MEANS Procedure
Type | N Obs | Variable | N | Mean | Median | Minimum | Maximum | Std Dev | Lower Quartile | Upper Quartile |
---|---|---|---|---|---|---|---|---|---|---|
Broiler | 13 | WeightKg PricePerKg SalesQty | 13 13 13 | 1.1576923 210.2307692 13.6153846 | 1.1000000 205.0000000 11.0000000 | 0.3500000 185.0000000 5.0000000 | 2.1000000 250.0000000 30.0000000 | 0.5302696 20.5513740 8.0056070 | 0.8500000 195.0000000 8.0000000 | 1.5000000 225.0000000 15.0000000 |
Country | 8 | WeightKg PricePerKg SalesQty | 8 8 8 | 1.2312500 284.1250000 3.8750000 | 1.1750000 285.0000000 1.5000000 | 0.5000000 260.0000000 1.0000000 | 2.0000000 305.0000000 20.0000000 | 0.5650142 15.4127730 6.5560768 | 0.7500000 272.5000000 1.0000000 | 1.7500000 296.5000000 2.5000000 |
Free-range | 8 | WeightKg PricePerKg SalesQty | 8 8 8 | 0.9562500 324.3750000 13.7500000 | 0.8750000 325.0000000 6.5000000 | 0.3000000 300.0000000 2.0000000 | 1.6000000 350.0000000 50.0000000 | 0.4459640 16.3526975 16.1488611 | 0.6500000 312.5000000 3.5000000 | 1.3500000 335.0000000 19.0000000 |
Layer | 7 | WeightKg PricePerKg SalesQty | 7 7 7 | 0.7285714 209.7142857 15.2857143 | 0.6000000 210.0000000 9.0000000 | 0.4000000 200.0000000 2.0000000 | 1.2000000 220.0000000 40.0000000 | 0.3186654 6.4990842 15.5960923 | 0.4500000 205.0000000 4.0000000 | 1.0500000 215.0000000 35.0000000 |
purpose: PROC UNIVARIATE examines distributional properties and outliers for numeric variables.
proc univariate data=chicken_india;
var PricePerKg WeightKg;
histogram PricePerKg / normal;
run;
Output:
The UNIVARIATE Procedure
Variable: PricePerKg
Moments | |||
---|---|---|---|
N | 36 | Sum Weights | 36 |
Mean | 251.916667 | Sum Observations | 9069 |
Std Deviation | 51.8830415 | Variance | 2691.85 |
Skewness | 0.3907722 | Kurtosis | -1.3501836 |
Uncorrected SS | 2378847 | Corrected SS | 94214.75 |
Coeff Variation | 20.5953192 | Std Error Mean | 8.64717359 |
Basic Statistical Measures | |||
---|---|---|---|
Location | Variability | ||
Mean | 251.9167 | Std Deviation | 51.88304 |
Median | 235.0000 | Variance | 2692 |
Mode | 210.0000 | Range | 165.00000 |
Interquartile Range | 92.50000 |
Tests for Location: Mu0=0 | ||||
---|---|---|---|---|
Test | Statistic | p Value | ||
Student's t | t | 29.13283 | Pr > |t| | <.0001 |
Sign | M | 18 | Pr >= |M| | <.0001 |
Signed Rank | S | 333 | Pr >= |S| | <.0001 |
Quantiles (Definition 5) | |
---|---|
Level | Quantile |
100% Max | 350.0 |
99% | 350.0 |
95% | 340.0 |
90% | 330.0 |
75% Q3 | 299.0 |
50% Median | 235.0 |
25% Q1 | 206.5 |
10% | 195.0 |
5% | 190.0 |
1% | 185.0 |
0% Min | 185.0 |
Extreme Observations | |||
---|---|---|---|
Lowest | Highest | ||
Value | Obs | Value | Obs |
185 | 6 | 320 | 10 |
190 | 31 | 330 | 25 |
190 | 20 | 330 | 34 |
195 | 1 | 340 | 21 |
198 | 29 | 350 | 14 |
The UNIVARIATE Procedure
The UNIVARIATE Procedure
Fitted Normal Distribution for PricePerKg
Parameters for Normal Distribution | ||
---|---|---|
Parameter | Symbol | Estimate |
Mean | Mu | 251.9167 |
Std Dev | Sigma | 51.88304 |
Goodness-of-Fit Tests for Normal Distribution | ||||
---|---|---|---|---|
Test | Statistic | p Value | ||
Kolmogorov-Smirnov | D | 0.17829068 | Pr > D | <0.010 |
Cramer-von Mises | W-Sq | 0.23894122 | Pr > W-Sq | <0.005 |
Anderson-Darling | A-Sq | 1.38500966 | Pr > A-Sq | <0.005 |
Quantiles for Normal Distribution | ||
---|---|---|
Percent | Quantile | |
Observed | Estimated | |
1.0 | 185.000 | 131.219 |
5.0 | 190.000 | 166.577 |
10.0 | 195.000 | 185.426 |
25.0 | 206.500 | 216.922 |
50.0 | 235.000 | 251.917 |
75.0 | 299.000 | 286.911 |
90.0 | 330.000 | 318.407 |
95.0 | 340.000 | 337.257 |
99.0 | 350.000 | 372.615 |
The UNIVARIATE Procedure
Variable: WeightKg
Moments | |||
---|---|---|---|
N | 36 | Sum Weights | 36 |
Mean | 1.04583333 | Sum Observations | 37.65 |
Std Deviation | 0.50190708 | Variance | 0.25191071 |
Skewness | 0.40761513 | Kurtosis | -0.7442929 |
Uncorrected SS | 48.1925 | Corrected SS | 8.816875 |
Coeff Variation | 47.991115 | Std Error Mean | 0.08365118 |
Basic Statistical Measures | |||
---|---|---|---|
Location | Variability | ||
Mean | 1.045833 | Std Deviation | 0.50191 |
Median | 0.975000 | Variance | 0.25191 |
Mode | 0.400000 | Range | 1.80000 |
Interquartile Range | 0.80000 |
Note: The mode displayed is the smallest of 9 modes with a count of 2.
Tests for Location: Mu0=0 | ||||
---|---|---|---|---|
Test | Statistic | p Value | ||
Student's t | t | 12.50231 | Pr > |t| | <.0001 |
Sign | M | 18 | Pr >= |M| | <.0001 |
Signed Rank | S | 333 | Pr >= |S| | <.0001 |
Quantiles (Definition 5) | |
---|---|
Level | Quantile |
100% Max | 2.100 |
99% | 2.100 |
95% | 2.000 |
90% | 1.800 |
75% Q3 | 1.400 |
50% Median | 0.975 |
25% Q1 | 0.600 |
10% | 0.400 |
5% | 0.350 |
1% | 0.300 |
0% Min | 0.300 |
Extreme Observations | |||
---|---|---|---|
Lowest | Highest | ||
Value | Obs | Value | Obs |
0.30 | 14 | 1.7 | 29 |
0.35 | 31 | 1.8 | 1 |
0.40 | 28 | 1.9 | 27 |
0.40 | 6 | 2.0 | 32 |
0.45 | 19 | 2.1 | 20 |
6) PROC SQL examples (joins, aggregations, derived table)
1) Aggregation by state and type
purpose: PROC SQL performs SQL-style grouping/aggregation and creates summary tables.
proc sql;
create table sales_summary as
select State, Type,
sum(SalesQty) as TotalSold,
mean(PricePerKg) as AvgPrice format=8.2,
mean(WeightKg) as AvgWeight format=8.2
from chicken_india
group by State, Type
order by State, Type;
quit;
proc print;run;
Output:
Obs | State | Type | TotalSold | AvgPrice | AvgWeight |
---|---|---|---|---|---|
1 | Andhra Pradesh | Broiler | 35 | 225.00 | 1.10 |
2 | Andhra Pradesh | Country | 3 | 270.00 | 0.50 |
3 | Bihar | Broiler | 9 | 240.00 | 0.95 |
4 | Chandigarh | Broiler | 15 | 225.00 | 1.40 |
5 | Chhattisgarh | Broiler | 14 | 215.00 | 1.10 |
6 | Gujarat | Country | 1 | 290.00 | 1.60 |
7 | Gujarat | Free-range | 7 | 310.00 | 1.30 |
8 | Himachal Prades | Free-range | 3 | 330.00 | 0.55 |
9 | Jharkhand | Country | 2 | 298.00 | 1.25 |
10 | Karnataka | Country | 1 | 280.00 | 1.10 |
11 | Madhya Pradesh | Broiler | 11 | 190.00 | 2.10 |
12 | Madhya Pradesh | Layer | 35 | 215.00 | 0.45 |
13 | Maharashtra | Broiler | 8 | 185.00 | 0.40 |
14 | Maharashtra | Free-range | 50 | 300.00 | 1.40 |
15 | Odisha | Broiler | 22 | 210.00 | 1.20 |
16 | Punjab | Country | 1 | 305.00 | 2.00 |
17 | Punjab | Free-range | 20 | 330.00 | 1.60 |
18 | Punjab | Layer | 9 | 208.00 | 0.50 |
19 | Rajasthan | Country | 2 | 275.00 | 0.60 |
20 | Rajasthan | Free-range | 6 | 340.00 | 0.75 |
21 | Tamil Nadu | Layer | 12 | 210.00 | 0.60 |
22 | Telangana | Broiler | 16 | 212.50 | 1.40 |
23 | Telangana | Country | 20 | 260.00 | 0.90 |
24 | Telangana | Free-range | 4 | 320.00 | 0.80 |
25 | Telangana | Layer | 2 | 220.00 | 1.20 |
26 | Uttar Pradesh | Broiler | 40 | 201.50 | 1.28 |
27 | Uttar Pradesh | Free-range | 2 | 350.00 | 0.30 |
28 | Uttar Pradesh | Layer | 49 | 205.00 | 0.78 |
29 | Uttrakhand | Country | 1 | 295.00 | 1.90 |
30 | West Bengal | Broiler | 7 | 190.00 | 0.35 |
31 | West Bengal | Free-range | 18 | 315.00 | 0.95 |
2) Finding top-selling records across India
purpose: PROC SQL can compute new variables and sort by calculated metrics.
proc sql outobs=10;
create table top_sales as
select *, SalesQty*PricePerKg as Revenue format=12.2
from chicken_india
order by Revenue desc;
quit;
proc print;run;
Output:
Obs | RecordID | Type | Breed | CutType | FeedType | Market | State | SellerType | ProcessingPlant | Cert | DateSold | WeightKg | PricePerKg | Vaccinated | Organic | Packaged | SalesQty | Revenue |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 5 | Free-range | Desi Free | Whole | Free-range | Mumbai | Maharashtra | Wholesale | PlantD | ISO | 2025-06-06 | 1.40 | 300 | Yes | Yes | No | 50 | 15000.00 |
2 | 13 | Layer | Commercial Layer | Legs | Grain-fed | Lucknow | Uttar Pradesh | Wholesale | PlantE | FSSAI | 2025-06-13 | 0.90 | 205 | Yes | No | No | 40 | 8200.00 |
3 | 19 | Layer | Desi Layer | Wings | Grain-fed | Indore | Madhya Pradesh | Wholesale | PlantE | FSSAI | 2025-06-17 | 0.45 | 215 | Yes | No | No | 35 | 7525.00 |
4 | 34 | Free-range | Desi Free | Legs | Free-range | Amritsar | Punjab | Wholesale | PlantD | ISO | 2025-06-25 | 1.60 | 330 | Yes | Yes | No | 20 | 6600.00 |
5 | 11 | Broiler | Venky Broiler | Whole | Commercial | Visakhapatnam | Andhra Pradesh | Wholesale | PlantA | AGMARK | 2025-06-11 | 1.50 | 200 | Yes | No | No | 30 | 6000.00 |
6 | 30 | Free-range | Desi Free | Breast | Free-range | Kolkata | West Bengal | Wholesale | PlantD | ISO | 2025-06-23 | 0.95 | 315 | Yes | Yes | No | 18 | 5670.00 |
7 | 23 | Broiler | Venky Broiler | Breast | Commercial | Agra | Uttar Pradesh | Wholesale | PlantA | AGMARK | 2025-06-19 | 0.85 | 205 | Yes | No | No | 27 | 5535.00 |
8 | 3 | Country | Desi Country | Legs | Free-range | Warangal | Telangana | Wholesale | PlantC | NoCert | 2025-06-05 | 0.90 | 260 | Yes | Yes | No | 20 | 5200.00 |
9 | 16 | Broiler | Venky Broiler | Legs | Commercial | Bhubaneswar | Odisha | Wholesale | PlantA | AGMARK | 2025-06-15 | 1.20 | 210 | Yes | No | No | 22 | 4620.00 |
10 | 26 | Broiler | Silver Broiler | Legs | Commercial | Chandigarh | Chandigarh | Wholesale | PlantA | AGMARK | 2025-06-20 | 1.40 | 225 | Yes | No | No | 15 | 3375.00 |
7) Data reshaping and reporting
purpose: PROC TRANSPOSE reshapes long->wide (or vice versa) for particular reporting layouts.
proc transpose data=sales_summary out=sales_transpose prefix=Val_;
by State;
id Type;
var TotalSold AvgPrice;
run;
proc print;run;
Output:
Obs | State | _NAME_ | Val_Broiler | Val_Country | Val_Free-range | Val_Layer |
---|---|---|---|---|---|---|
1 | Andhra Pradesh | TotalSold | 35.0 | 3 | . | . |
2 | Andhra Pradesh | AvgPrice | 225.0 | 270 | . | . |
3 | Bihar | TotalSold | 9.0 | . | . | . |
4 | Bihar | AvgPrice | 240.0 | . | . | . |
5 | Chandigarh | TotalSold | 15.0 | . | . | . |
6 | Chandigarh | AvgPrice | 225.0 | . | . | . |
7 | Chhattisgarh | TotalSold | 14.0 | . | . | . |
8 | Chhattisgarh | AvgPrice | 215.0 | . | . | . |
9 | Gujarat | TotalSold | . | 1 | 7 | . |
10 | Gujarat | AvgPrice | . | 290 | 310 | . |
11 | Himachal Prades | TotalSold | . | . | 3 | . |
12 | Himachal Prades | AvgPrice | . | . | 330 | . |
13 | Jharkhand | TotalSold | . | 2 | . | . |
14 | Jharkhand | AvgPrice | . | 298 | . | . |
15 | Karnataka | TotalSold | . | 1 | . | . |
16 | Karnataka | AvgPrice | . | 280 | . | . |
17 | Madhya Pradesh | TotalSold | 11.0 | . | . | 35 |
18 | Madhya Pradesh | AvgPrice | 190.0 | . | . | 215 |
19 | Maharashtra | TotalSold | 8.0 | . | 50 | . |
20 | Maharashtra | AvgPrice | 185.0 | . | 300 | . |
21 | Odisha | TotalSold | 22.0 | . | . | . |
22 | Odisha | AvgPrice | 210.0 | . | . | . |
23 | Punjab | TotalSold | . | 1 | 20 | 9 |
24 | Punjab | AvgPrice | . | 305 | 330 | 208 |
25 | Rajasthan | TotalSold | . | 2 | 6 | . |
26 | Rajasthan | AvgPrice | . | 275 | 340 | . |
27 | Tamil Nadu | TotalSold | . | . | . | 12 |
28 | Tamil Nadu | AvgPrice | . | . | . | 210 |
29 | Telangana | TotalSold | 16.0 | 20 | 4 | 2 |
30 | Telangana | AvgPrice | 212.5 | 260 | 320 | 220 |
31 | Uttar Pradesh | TotalSold | 40.0 | . | 2 | 49 |
32 | Uttar Pradesh | AvgPrice | 201.5 | . | 350 | 205 |
33 | Uttrakhand | TotalSold | . | 1 | . | . |
34 | Uttrakhand | AvgPrice | . | 295 | . | . |
35 | West Bengal | TotalSold | 7.0 | . | 18 | . |
36 | West Bengal | AvgPrice | 190.0 | . | 315 | . |
purpose: PROC REPORT creates formatted tables (customizable) for publication-ready output.
proc report data=sales_summary nowd;
columns State Type TotalSold AvgPrice AvgWeight;
define State / group;
define Type / across;
define TotalSold / sum;
run;
Output:
Type | |||||||
---|---|---|---|---|---|---|---|
State | Broiler | Country | Free-range | Layer | TotalSold | AvgPrice | AvgWeight |
Andhra Pradesh | 1 | 1 | . | . | 38 | 495.00 | 1.60 |
Bihar | 1 | . | . | . | 9 | 240.00 | 0.95 |
Chandigarh | 1 | . | . | . | 15 | 225.00 | 1.40 |
Chhattisgarh | 1 | . | . | . | 14 | 215.00 | 1.10 |
Gujarat | . | 1 | 1 | . | 8 | 600.00 | 2.90 |
Himachal Prades | . | . | 1 | . | 3 | 330.00 | 0.55 |
Jharkhand | . | 1 | . | . | 2 | 298.00 | 1.25 |
Karnataka | . | 1 | . | . | 1 | 280.00 | 1.10 |
Madhya Pradesh | 1 | . | . | 1 | 46 | 405.00 | 2.55 |
Maharashtra | 1 | . | 1 | . | 58 | 485.00 | 1.80 |
Odisha | 1 | . | . | . | 22 | 210.00 | 1.20 |
Punjab | . | 1 | 1 | 1 | 30 | 843.00 | 4.10 |
Rajasthan | . | 1 | 1 | . | 8 | 615.00 | 1.35 |
Tamil Nadu | . | . | . | 1 | 12 | 210.00 | 0.60 |
Telangana | 1 | 1 | 1 | 1 | 42 | 1012.50 | 4.30 |
Uttar Pradesh | 1 | . | 1 | 1 | 91 | 756.50 | 2.36 |
Uttrakhand | . | 1 | . | . | 1 | 295.00 | 1.90 |
West Bengal | 1 | . | 1 | . | 25 | 505.00 | 1.30 |
8) Tabulate and summary tables
purpose: PROC TABULATE builds multi-dimensional summary tables with compact syntax.
proc tabulate data=chicken_india;
class State Type SellerType;
var PricePerKg WeightKg SalesQty;
table State, Type* (n sum*SalesQty mean*PricePerKg);
run;
Output:
Type | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Broiler | Country | Free-range | Layer | |||||||||
N | Sum | Mean | N | Sum | Mean | N | Sum | Mean | N | Sum | Mean | |
SalesQty | PricePerKg | SalesQty | PricePerKg | SalesQty | PricePerKg | SalesQty | PricePerKg | |||||
State | 2 | 35.00 | 225.00 | 1 | 3.00 | 270.00 | . | . | . | . | . | . |
Andhra Pradesh | ||||||||||||
Bihar | 1 | 9.00 | 240.00 | . | . | . | . | . | . | . | . | . |
Chandigarh | 1 | 15.00 | 225.00 | . | . | . | . | . | . | . | . | . |
Chhattisgarh | 1 | 14.00 | 215.00 | . | . | . | . | . | . | . | . | . |
Gujarat | . | . | . | 1 | 1.00 | 290.00 | 1 | 7.00 | 310.00 | . | . | . |
Himachal Prades | . | . | . | . | . | . | 1 | 3.00 | 330.00 | . | . | . |
Jharkhand | . | . | . | 1 | 2.00 | 298.00 | . | . | . | . | . | . |
Karnataka | . | . | . | 1 | 1.00 | 280.00 | . | . | . | . | . | . |
Madhya Pradesh | 1 | 11.00 | 190.00 | . | . | . | . | . | . | 1 | 35.00 | 215.00 |
Maharashtra | 1 | 8.00 | 185.00 | . | . | . | 1 | 50.00 | 300.00 | . | . | . |
Odisha | 1 | 22.00 | 210.00 | . | . | . | . | . | . | . | . | . |
Punjab | . | . | . | 1 | 1.00 | 305.00 | 1 | 20.00 | 330.00 | 1 | 9.00 | 208.00 |
Rajasthan | . | . | . | 1 | 2.00 | 275.00 | 1 | 6.00 | 340.00 | . | . | . |
Tamil Nadu | . | . | . | . | . | . | . | . | . | 1 | 12.00 | 210.00 |
Telangana | 2 | 16.00 | 212.50 | 1 | 20.00 | 260.00 | 1 | 4.00 | 320.00 | 1 | 2.00 | 220.00 |
Uttar Pradesh | 2 | 40.00 | 201.50 | . | . | . | 1 | 2.00 | 350.00 | 3 | 49.00 | 205.00 |
Uttrakhand | . | . | . | 1 | 1.00 | 295.00 | . | . | . | . | . | . |
West Bengal | 1 | 7.00 | 190.00 | . | . | . | 1 | 18.00 | 315.00 | . | . | . |
9) Data quality checks using DATA step and PROC FREQ
Create QC flags
purpose: DATA step generates QC flags and derived variables for validation.
data chicken_qc;
set chicken_india;
if PricePerKg <= 0 then Price_flag='Bad';
else Price_flag='OK';
if WeightKg <= 0 or WeightKg > 5 then Weight_flag='Check';
else Weight_flag='OK';
run;
proc print;run;
Output:
Obs | RecordID | Type | Breed | CutType | FeedType | Market | State | SellerType | ProcessingPlant | Cert | DateSold | WeightKg | PricePerKg | Vaccinated | Organic | Packaged | SalesQty | Price_flag | Weight_flag |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 1 | Broiler | Venky Broiler | Whole | Commercial | Secunderabad | Telangana | Retail | PlantA | AGMARK | 2025-06-02 | 1.80 | 195 | Yes | No | No | 10 | OK | OK |
2 | 2 | Layer | Desi Layer | Whole | Grain-fed | Hyderabad | Telangana | Backyard | PlantB | NoCert | 2025-06-03 | 1.20 | 220 | Yes | Yes | No | 2 | OK | OK |
3 | 3 | Country | Desi Country | Legs | Free-range | Warangal | Telangana | Wholesale | PlantC | NoCert | 2025-06-05 | 0.90 | 260 | Yes | Yes | No | 20 | OK | OK |
4 | 4 | Broiler | Silver Broiler | Breast | Commercial | Vijayawada | Andhra Pradesh | Retail | PlantA | AGMARK | 2025-06-05 | 0.70 | 250 | Yes | No | Yes | 5 | OK | OK |
5 | 5 | Free-range | Desi Free | Whole | Free-range | Mumbai | Maharashtra | Wholesale | PlantD | ISO | 2025-06-06 | 1.40 | 300 | Yes | Yes | No | 50 | OK | OK |
6 | 6 | Broiler | Venky Broiler | Wings | Commercial | Pune | Maharashtra | Retail | PlantA | AGMARK | 2025-06-07 | 0.40 | 185 | Yes | No | No | 8 | OK | OK |
7 | 7 | Layer | Commercial Layer | Breast | Grain-fed | Chennai | Tamil Nadu | Supermarket | PlantE | FSSAI | 2025-06-07 | 0.60 | 210 | Yes | No | Yes | 12 | OK | OK |
8 | 8 | Country | Desi Country | Whole | BackyardFeed | Bengaluru | Karnataka | Backyard | PlantC | NoCert | 2025-06-08 | 1.10 | 280 | Yes | Yes | No | 1 | OK | OK |
9 | 9 | Broiler | Silver Broiler | Legs | Commercial | Secunderabad | Telangana | Retail | PlantA | AGMARK | 2025-06-09 | 1.00 | 230 | Yes | No | Yes | 6 | OK | OK |
10 | 10 | Free-range | Desi Free | Breast | Free-range | Hyderabad | Telangana | Supermarket | PlantD | ISO | 2025-06-10 | 0.80 | 320 | Yes | Yes | Yes | 4 | OK | OK |
11 | 11 | Broiler | Venky Broiler | Whole | Commercial | Visakhapatnam | Andhra Pradesh | Wholesale | PlantA | AGMARK | 2025-06-11 | 1.50 | 200 | Yes | No | No | 30 | OK | OK |
12 | 12 | Country | Desi Country | Wings | BackyardFeed | Vijayawada | Andhra Pradesh | Backyard | PlantC | NoCert | 2025-06-12 | 0.50 | 270 | Yes | Yes | No | 3 | OK | OK |
13 | 13 | Layer | Commercial Layer | Legs | Grain-fed | Lucknow | Uttar Pradesh | Wholesale | PlantE | FSSAI | 2025-06-13 | 0.90 | 205 | Yes | No | No | 40 | OK | OK |
14 | 14 | Free-range | Desi Free | Wings | Free-range | Kanpur | Uttar Pradesh | Retail | PlantD | ISO | 2025-06-14 | 0.30 | 350 | Yes | Yes | No | 2 | OK | OK |
15 | 15 | Broiler | Silver Broiler | Breast | Commercial | Patna | Bihar | Supermarket | PlantA | AGMARK | 2025-06-14 | 0.95 | 240 | Yes | No | Yes | 9 | OK | OK |
16 | 16 | Broiler | Venky Broiler | Legs | Commercial | Bhubaneswar | Odisha | Wholesale | PlantA | AGMARK | 2025-06-15 | 1.20 | 210 | Yes | No | No | 22 | OK | OK |
17 | 17 | Country | Desi Country | Whole | BackyardFeed | Ahmedabad | Gujarat | Backyard | PlantC | NoCert | 2025-06-16 | 1.60 | 290 | Yes | Yes | No | 1 | OK | OK |
18 | 18 | Free-range | Desi Free | Legs | Free-range | Surat | Gujarat | Retail | PlantD | ISO | 2025-06-16 | 1.30 | 310 | Yes | Yes | No | 7 | OK | OK |
19 | 19 | Layer | Desi Layer | Wings | Grain-fed | Indore | Madhya Pradesh | Wholesale | PlantE | FSSAI | 2025-06-17 | 0.45 | 215 | Yes | No | No | 35 | OK | OK |
20 | 20 | Broiler | Silver Broiler | Whole | Commercial | Bhopal | Madhya Pradesh | Retail | PlantA | AGMARK | 2025-06-17 | 2.10 | 190 | Yes | No | No | 11 | OK | OK |
21 | 21 | Free-range | Desi Free | Breast | Free-range | Jaipur | Rajasthan | Supermarket | PlantD | ISO | 2025-06-18 | 0.75 | 340 | Yes | Yes | Yes | 6 | OK | OK |
22 | 22 | Country | Desi Country | Wings | BackyardFeed | Udaipur | Rajasthan | Backyard | PlantC | NoCert | 2025-06-18 | 0.60 | 275 | Yes | Yes | No | 2 | OK | OK |
23 | 23 | Broiler | Venky Broiler | Breast | Commercial | Agra | Uttar Pradesh | Wholesale | PlantA | AGMARK | 2025-06-19 | 0.85 | 205 | Yes | No | No | 27 | OK | OK |
24 | 24 | Layer | Commercial Layer | Whole | Grain-fed | Varanasi | Uttar Pradesh | Retail | PlantE | FSSAI | 2025-06-19 | 1.05 | 200 | Yes | No | No | 4 | OK | OK |
25 | 25 | Free-range | Desi Free | Wings | Free-range | Shimla | Himachal Prades | Supermarket | PlantD | ISO | 2025-06-20 | 0.55 | 330 | Yes | Yes | No | 3 | OK | OK |
26 | 26 | Broiler | Silver Broiler | Legs | Commercial | Chandigarh | Chandigarh | Wholesale | PlantA | AGMARK | 2025-06-20 | 1.40 | 225 | Yes | No | No | 15 | OK | OK |
27 | 27 | Country | Desi Country | Breast | BackyardFeed | Dehradun | Uttrakhand | Backyard | PlantC | NoCert | 2025-06-21 | 1.90 | 295 | Yes | Yes | No | 1 | OK | OK |
28 | 28 | Layer | Desi Layer | Legs | Grain-fed | Noida | Uttar Pradesh | Supermarket | PlantE | FSSAI | 2025-06-21 | 0.40 | 210 | Yes | No | Yes | 5 | OK | OK |
29 | 29 | Broiler | Venky Broiler | Whole | Commercial | Ghaziabad | Uttar Pradesh | Retail | PlantA | AGMARK | 2025-06-22 | 1.70 | 198 | Yes | No | No | 13 | OK | OK |
30 | 30 | Free-range | Desi Free | Breast | Free-range | Kolkata | West Bengal | Wholesale | PlantD | ISO | 2025-06-23 | 0.95 | 315 | Yes | Yes | No | 18 | OK | OK |
31 | 31 | Broiler | Silver Broiler | Wings | Commercial | Asansol | West Bengal | Supermarket | PlantA | AGMARK | 2025-06-24 | 0.35 | 190 | Yes | No | Yes | 7 | OK | OK |
32 | 32 | Country | Desi Country | Whole | BackyardFeed | Patiala | Punjab | Backyard | PlantC | NoCert | 2025-06-24 | 2.00 | 305 | Yes | Yes | No | 1 | OK | OK |
33 | 33 | Layer | Commercial Layer | Wings | Grain-fed | Ludhiana | Punjab | Retail | PlantE | FSSAI | 2025-06-25 | 0.50 | 208 | Yes | No | No | 9 | OK | OK |
34 | 34 | Free-range | Desi Free | Legs | Free-range | Amritsar | Punjab | Wholesale | PlantD | ISO | 2025-06-25 | 1.60 | 330 | Yes | Yes | No | 20 | OK | OK |
35 | 35 | Broiler | Venky Broiler | Breast | Commercial | Raipur | Chhattisgarh | Retail | PlantA | AGMARK | 2025-06-26 | 1.10 | 215 | Yes | No | No | 14 | OK | OK |
36 | 36 | Country | Desi Country | Breast | BackyardFeed | Ranchi | Jharkhand | Backyard | PlantC | NoCert | 2025-06-26 | 1.25 | 298 | Yes | Yes | No | 2 | OK | OK |
purpose: PROC FREQ inspects QC flag distributions to find anomalies.
proc freq data=chicken_qc;
tables Price_flag Weight_flag Cert;
run;
Output:
The FREQ Procedure
Price_flag | Frequency | Percent | Cumulative Frequency | Cumulative Percent |
---|---|---|---|---|
OK | 36 | 100.00 | 36 | 100.00 |
Weight_flag | Frequency | Percent | Cumulative Frequency | Cumulative Percent |
---|---|---|---|---|
OK | 36 | 100.00 | 36 | 100.00 |
Cert | Frequency | Percent | Cumulative Frequency | Cumulative Percent |
---|---|---|---|---|
AGMARK | 13 | 36.11 | 13 | 36.11 |
FSSAI | 6 | 16.67 | 19 | 52.78 |
ISO | 8 | 22.22 | 27 | 75.00 |
NoCert | 9 | 25.00 | 36 | 100.00 |
10) Advanced: macros (generation, batch reports, parameterization)
Macro 1: create a report filtered by state
purpose: %state_report generates state-specific summary tables and prints—parameterized reporting.
%macro state_report(st=);
proc sql;
create table state_&st. as
select *, SalesQty*PricePerKg as Revenue format=12.2
from chicken_india
where upcase(State)=upcase("&st.");
quit;
proc means data=state_&st. n mean median min max;
var PricePerKg WeightKg SalesQty Revenue;
run;
proc print data=state_&st.(obs=15);
title "Sample records for state &st.";
run;
%mend state_report;
Macro 2: run state_report for a list of states
purpose: %batch_states loops macros to run repeated reports for many states in a single call.
%macro batch_states(states_list);
%local i s next;
%let i=1;
%do %while(%scan(&states_list., &i.) ne );
%let s = %scan(&states_list., &i.);
%state_report(st=&s);
%let i=%eval(&i.+1);
%end;
%mend batch_states;
Macro 3: create an aggregated exported CSV
purpose: %export_summary creates aggregated CSV exports for downstream use.
%macro export_summary(outpath=/tmp);
proc sql;
create table summary_all as
select Type, FeedType, sum(SalesQty) as Qty, round(mean(PricePerKg),0.01) as AvgPrice
from chicken_india
group by Type, FeedType;
quit;
proc export data=summary_all
outfile="&outpath./chicken_summary.csv"
dbms=csv replace;
run;
%mend export_summary;
11) Example macro calls (actual runs)
%state_report(st=Telangana);
Output:
The MEANS Procedure
Variable | N | Mean | Median | Minimum | Maximum |
---|---|---|---|---|---|
PricePerKg WeightKg SalesQty Revenue | 5 5 5 5 | 245.0000000 1.1400000 8.4000000 2050.00 | 230.0000000 1.0000000 6.0000000 1380.00 | 195.0000000 0.8000000 2.0000000 440.0000000 | 320.0000000 1.8000000 20.0000000 5200.00 |
Sample records for state Telangana
Obs | RecordID | Type | Breed | CutType | FeedType | Market | State | SellerType | ProcessingPlant | Cert | DateSold | WeightKg | PricePerKg | Vaccinated | Organic | Packaged | SalesQty | Revenue |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 1 | Broiler | Venky Broiler | Whole | Commercial | Secunderabad | Telangana | Retail | PlantA | AGMARK | 2025-06-02 | 1.8 | 195 | Yes | No | No | 10 | 1950.00 |
2 | 2 | Layer | Desi Layer | Whole | Grain-fed | Hyderabad | Telangana | Backyard | PlantB | NoCert | 2025-06-03 | 1.2 | 220 | Yes | Yes | No | 2 | 440.00 |
3 | 3 | Country | Desi Country | Legs | Free-range | Warangal | Telangana | Wholesale | PlantC | NoCert | 2025-06-05 | 0.9 | 260 | Yes | Yes | No | 20 | 5200.00 |
4 | 9 | Broiler | Silver Broiler | Legs | Commercial | Secunderabad | Telangana | Retail | PlantA | AGMARK | 2025-06-09 | 1.0 | 230 | Yes | No | Yes | 6 | 1380.00 |
5 | 10 | Free-range | Desi Free | Breast | Free-range | Hyderabad | Telangana | Supermarket | PlantD | ISO | 2025-06-10 | 0.8 | 320 | Yes | Yes | Yes | 4 | 1280.00 |
%batch_states(states_list=Telangana Maharashtra Andhra Pradesh Uttar Pradesh);
Output:
The MEANS Procedure
Variable | N | Mean | Median | Minimum | Maximum |
---|---|---|---|---|---|
PricePerKg WeightKg SalesQty Revenue | 5 5 5 5 | 245.0000000 1.1400000 8.4000000 2050.00 | 230.0000000 1.0000000 6.0000000 1380.00 | 195.0000000 0.8000000 2.0000000 440.0000000 | 320.0000000 1.8000000 20.0000000 5200.00 |
Sample records for state Telangana
Obs | RecordID | Type | Breed | CutType | FeedType | Market | State | SellerType | ProcessingPlant | Cert | DateSold | WeightKg | PricePerKg | Vaccinated | Organic | Packaged | SalesQty | Revenue |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 1 | Broiler | Venky Broiler | Whole | Commercial | Secunderabad | Telangana | Retail | PlantA | AGMARK | 2025-06-02 | 1.8 | 195 | Yes | No | No | 10 | 1950.00 |
2 | 2 | Layer | Desi Layer | Whole | Grain-fed | Hyderabad | Telangana | Backyard | PlantB | NoCert | 2025-06-03 | 1.2 | 220 | Yes | Yes | No | 2 | 440.00 |
3 | 3 | Country | Desi Country | Legs | Free-range | Warangal | Telangana | Wholesale | PlantC | NoCert | 2025-06-05 | 0.9 | 260 | Yes | Yes | No | 20 | 5200.00 |
4 | 9 | Broiler | Silver Broiler | Legs | Commercial | Secunderabad | Telangana | Retail | PlantA | AGMARK | 2025-06-09 | 1.0 | 230 | Yes | No | Yes | 6 | 1380.00 |
5 | 10 | Free-range | Desi Free | Breast | Free-range | Hyderabad | Telangana | Supermarket | PlantD | ISO | 2025-06-10 | 0.8 | 320 | Yes | Yes | Yes | 4 | 1280.00 |
Sample records for state Telangana
The MEANS Procedure
Variable | N | Mean | Median | Minimum | Maximum |
---|---|---|---|---|---|
PricePerKg WeightKg SalesQty Revenue | 2 2 2 2 | 242.5000000 0.9000000 29.0000000 8240.00 | 242.5000000 0.9000000 29.0000000 8240.00 | 185.0000000 0.4000000 8.0000000 1480.00 | 300.0000000 1.4000000 50.0000000 15000.00 |
Sample records for state Maharashtra
Obs | RecordID | Type | Breed | CutType | FeedType | Market | State | SellerType | ProcessingPlant | Cert | DateSold | WeightKg | PricePerKg | Vaccinated | Organic | Packaged | SalesQty | Revenue |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 5 | Free-range | Desi Free | Whole | Free-range | Mumbai | Maharashtra | Wholesale | PlantD | ISO | 2025-06-06 | 1.4 | 300 | Yes | Yes | No | 50 | 15000.00 |
2 | 6 | Broiler | Venky Broiler | Wings | Commercial | Pune | Maharashtra | Retail | PlantA | AGMARK | 2025-06-07 | 0.4 | 185 | Yes | No | No | 8 | 1480.00 |
%export_summary(outpath=/home/user);
12) Graphs (visualization)
purpose: PROC SGPLOT draws charts (bar/line/scatter) to visualize patterns quickly.
proc sgplot data=chicken_india;
vbar Type / response=SalesQty stat=sum datalabel;
title "Total SalesQty by Type";
run;
Output:
13) Merge / join examples (combine with a plant lookup table)
data plants;
infile datalines dlm=',' dsd truncover;
length ProcessingPlant $20 PlantCity $20 Capacity 8;
input ProcessingPlant $ PlantCity $ Capacity;
datalines;
PlantA,Hyderabad,1000
PlantB,Chennai,500
PlantC,Secunderabad,200
PlantD,Mumbai,800
PlantE,Delhi,600
;
run;
proc print;run;
Output:
Obs | ProcessingPlant | PlantCity | Capacity |
---|---|---|---|
1 | PlantA | Hyderabad | 1000 |
2 | PlantB | Chennai | 500 |
3 | PlantC | Secunderabad | 200 |
4 | PlantD | Mumbai | 800 |
5 | PlantE | Delhi | 600 |
proc sort data=chicken_india out=chick_s; by ProcessingPlant; run;
proc sort data=plants out=plants_s; by ProcessingPlant; run;
purpose: DATA step merge joins datasets by key to append plant metadata.
data chick_with_plant;
merge chick_s(in=a) plants_s(in=b);
by ProcessingPlant;
if a;
run;
proc print data=chick_with_plant(obs=10);
run;
Output:
Obs | RecordID | Type | Breed | CutType | FeedType | Market | State | SellerType | ProcessingPlant | Cert | DateSold | WeightKg | PricePerKg | Vaccinated | Organic | Packaged | SalesQty | PlantCity | Capacity |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 1 | Broiler | Venky Broiler | Whole | Commercial | Secunderabad | Telangana | Retail | PlantA | AGMARK | 2025-06-02 | 1.80 | 195 | Yes | No | No | 10 | Hyderabad | 1000 |
2 | 4 | Broiler | Silver Broiler | Breast | Commercial | Vijayawada | Andhra Pradesh | Retail | PlantA | AGMARK | 2025-06-05 | 0.70 | 250 | Yes | No | Yes | 5 | Hyderabad | 1000 |
3 | 6 | Broiler | Venky Broiler | Wings | Commercial | Pune | Maharashtra | Retail | PlantA | AGMARK | 2025-06-07 | 0.40 | 185 | Yes | No | No | 8 | Hyderabad | 1000 |
4 | 9 | Broiler | Silver Broiler | Legs | Commercial | Secunderabad | Telangana | Retail | PlantA | AGMARK | 2025-06-09 | 1.00 | 230 | Yes | No | Yes | 6 | Hyderabad | 1000 |
5 | 11 | Broiler | Venky Broiler | Whole | Commercial | Visakhapatnam | Andhra Pradesh | Wholesale | PlantA | AGMARK | 2025-06-11 | 1.50 | 200 | Yes | No | No | 30 | Hyderabad | 1000 |
6 | 15 | Broiler | Silver Broiler | Breast | Commercial | Patna | Bihar | Supermarket | PlantA | AGMARK | 2025-06-14 | 0.95 | 240 | Yes | No | Yes | 9 | Hyderabad | 1000 |
7 | 16 | Broiler | Venky Broiler | Legs | Commercial | Bhubaneswar | Odisha | Wholesale | PlantA | AGMARK | 2025-06-15 | 1.20 | 210 | Yes | No | No | 22 | Hyderabad | 1000 |
8 | 20 | Broiler | Silver Broiler | Whole | Commercial | Bhopal | Madhya Pradesh | Retail | PlantA | AGMARK | 2025-06-17 | 2.10 | 190 | Yes | No | No | 11 | Hyderabad | 1000 |
9 | 23 | Broiler | Venky Broiler | Breast | Commercial | Agra | Uttar Pradesh | Wholesale | PlantA | AGMARK | 2025-06-19 | 0.85 | 205 | Yes | No | No | 27 | Hyderabad | 1000 |
10 | 26 | Broiler | Silver Broiler | Legs | Commercial | Chandigarh | Chandigarh | Wholesale | PlantA | AGMARK | 2025-06-20 | 1.40 | 225 | Yes | No | No | 15 | Hyderabad | 1000 |
14) Data extracts and export
purpose: PROC EXPORT writes datasets to external files (CSV, XLSX) for sharing or downstream systems.
proc export data=top_sales
outfile="/home/user/top_chicken_sales.csv"
dbms=csv replace;
run;
15) Validation and checks (example QC report macro)
purpose: %qc_report summarizes key data quality metrics and categorical completeness.
%macro qc_report();
proc sql;
select count(*) as TotalRec, sum(case when PricePerKg<=0 then 1 else 0 end) as PriceBad,
sum(case when WeightKg<=0 then 1 else 0 end) as WeightZero
from chicken_india;
quit;
proc freq data=chicken_india;
tables Cert Packaged Vaccinated Organic / missing;
run;
%mend qc_report;
%qc_report();
TotalRec | PriceBad | WeightZero |
---|---|---|
36 | 0 | 0 |
The FREQ Procedure
Cert | Frequency | Percent | Cumulative Frequency | Cumulative Percent |
---|---|---|---|---|
AGMARK | 13 | 36.11 | 13 | 36.11 |
FSSAI | 6 | 16.67 | 19 | 52.78 |
ISO | 8 | 22.22 | 27 | 75.00 |
NoCert | 9 | 25.00 | 36 | 100.00 |
Packaged | Frequency | Percent | Cumulative Frequency | Cumulative Percent |
---|---|---|---|---|
No | 28 | 77.78 | 28 | 77.78 |
Yes | 8 | 22.22 | 36 | 100.00 |
Vaccinated | Frequency | Percent | Cumulative Frequency | Cumulative Percent |
---|---|---|---|---|
Yes | 36 | 100.00 | 36 | 100.00 |
Organic | Frequency | Percent | Cumulative Frequency | Cumulative Percent |
---|---|---|---|---|
No | 19 | 52.78 | 19 | 52.78 |
Yes | 17 | 47.22 | 36 | 100.00 |
- Get link
- X
- Other Apps
Comments
Post a Comment