Wednesday, 20 August 2025

266.GLOBAL MAIZE (CORN) ANALYSIS — DATA CREATION | PROC FORMAT | PROC CONTENTS | PROC SORT | PROC PRINT | PROC FREQ | PROC MEANS | PROC SUMMARY | PROC UNIVARIATE | PROC TABULATE | PROC REPORT | PROC TRANSPOSE | PROC SQL | PROC RANK | PROC SGPLOT | MACROS | IN SAS

GLOBAL MAIZE (CORN) ANALYSIS — DATA CREATION | PROC FORMAT | PROC CONTENTS | PROC SORT | PROC PRINT | PROC FREQ | PROC MEANS | PROC SUMMARY | PROC UNIVARIATE | PROC TABULATE | PROC REPORT | PROC TRANSPOSE | PROC SQL | PROC RANK | PROC SGPLOT | MACROS | IN SAS

/*Creating a dataset of maize (corn) across the world*/

1) FORMATS: continent/region/seed type for readable output;

proc format;

  value $continent

    'AF'='Africa' 'AS'='Asia' 'EU'='Europe' 'NA'='North America'

    'SA'='South America' 'OC'='Oceania';

  value $region

    'EA'='East Africa' 'WA'='West Africa' 'NAF'='North Africa'

    'SEA'='Southeast Asia' 'EAH'='East Asia (High Income)'

    'SAH'='South Asia (High Income)' 'CAS'='Central Asia'

    'EEU'='Eastern Europe' 'WEU'='Western Europe'

    'NAM'='North America (Mainland)' 'CAR'='Caribbean'

    'AND'='Andean' 'CSS'='Cono Sur + Southern SA'

    'AUS'='Australia & NZ' 'PAC'='Pacific Islands';

  value $seedfmt

    'HYB'='Hybrid' 'OPV'='Open-Pollinated' 'GMO'='GM/Hybrid';

run;

Log:

NOTE: Format $CONTINENT has been output.
NOTE: Format $REGION has been output.
NOTE: Format $SEEDFMT has been output.

2) DATA: MAIZE PRODUCTION BY COUNTRY × YEAR (2023–2024);

data maize_world;

    length Country $30 Cont $2 Reg $4 Seed_Type $3;

    input Year 

          Country $ 

          Cont $ 

          Reg $ 

          Seed_Type $

          Area_HA 

          Production_Tonnes 

          Yield_T_HA 

          Rainfall_mm 

          Irrigated_Pct 

          Fertilizer_kg_ha 

          Mechanization_Idx 

          Export_Tonnes 

          Import_Tonnes 

          Price_USD_Ton;


    label Cont='Continent'

          Reg='Region'

          Area_HA='Harvested Area (ha)'

          Production_Tonnes='Production (tonnes)'

          Yield_T_HA='Yield (tonnes/ha)'

          Rainfall_mm='Growing-Season Rainfall (mm)'

          Irrigated_Pct='% Area Irrigated'

          Fertilizer_kg_ha='Fertilizer Use (kg/ha)'

          Mechanization_Idx='Mechanization Index (0–100)'

          Export_Tonnes='Exports (tonnes)'

          Import_Tonnes='Imports (tonnes)'

          Price_USD_Ton='Farmgate Price (USD/ton)'

          Seed_Type='Seed Category';

datalines;

2023 United_States NA NAM GMO 37000000 390000000 10.5 480 22 190 92 60000000 1500000 18

2024 United_States NA NAM GMO 37200000 400000000 10.8 475 23 192 93 62000000 1200000 17

2023 China AS EAH HYB 43000000 290000000 6.7 540 41 175 78 8000000 3500000 21

2024 China AS EAH HYB 43200000 298000000 6.9 545 42 178 79 9000000 3200000 20

2023 Brazil SA CSS GMO 21000000 135000000 6.4 520 34 160 75 28000000 900000 17

2024 Brazil SA CSS GMO 21500000 142000000 6.6 515 35 162 76 30000000 700000 16

2023 India AS SAH HYB 10000000 34000000 3.4 620 45 120 55 700000 2200000 20

2024 India AS SAH HYB 10200000 36000000 3.5 615 46 122 56 900000 2100000 19

2023 Argentina SA CSS GMO 7000000 52000000 7.4 470 21 165 80 16000000 300000 17

2024 Argentina SA CSS GMO 7200000 54000000 7.5 465 22 168 81 17000000 250000 17

2023 Mexico NA NAM HYB 7800000 27500000 3.5 580 33 130 65 900000 6000000 22

2024 Mexico NA NAM HYB 7900000 28500000 3.6 575 34 132 66 950000 5800000 21

2023 Ukraine EU EEU HYB 5200000 31000000 6.0 520 29 150 70 7000000 200000 18

2024 Ukraine EU EEU HYB 5400000 33000000 6.1 515 30 152 71 7500000 180000 18

2023 France EU WEU HYB 2700000 17500000 6.5 500 28 165 88 4500000 150000 19

2024 France EU WEU HYB 2750000 18200000 6.6 495 29 167 88 4600000 130000 19

2023 South_Africa AF WA HYB 3000000 12500000 4.2 430 18 135 72 2500000 100000 19

2024 South_Africa AF WA HYB 3050000 12800000 4.2 425 19 137 72 2600000 90000 18

2023 Nigeria AF WA OPV 5500000 14500000 2.6 740 10 60 25 200000 1200000 22

2024 Nigeria AF WA OPV 5600000 15000000 2.7 730 11 62 26 220000 1100000 22

;

run;

proc print data=maize_world; 

run;

Output:

ObsCountryContRegSeed_TypeYearArea_HAProduction_TonnesYield_T_HARainfall_mmIrrigated_PctFertilizer_kg_haMechanization_IdxExport_TonnesImport_TonnesPrice_USD_Ton
1United_StatesNANAMGMO20233700000039000000010.5480221909260000000150000018
2United_StatesNANAMGMO20243720000040000000010.8475231929362000000120000017
3ChinaASEAHHYB2023430000002900000006.754041175788000000350000021
4ChinaASEAHHYB2024432000002980000006.954542178799000000320000020
5BrazilSACSSGMO2023210000001350000006.452034160752800000090000017
6BrazilSACSSGMO2024215000001420000006.651535162763000000070000016
7IndiaASSAHHYB202310000000340000003.46204512055700000220000020
8IndiaASSAHHYB202410200000360000003.56154612256900000210000019
9ArgentinaSACSSGMO20237000000520000007.447021165801600000030000017
10ArgentinaSACSSGMO20247200000540000007.546522168811700000025000017
11MexicoNANAMHYB20237800000275000003.55803313065900000600000022
12MexicoNANAMHYB20247900000285000003.65753413266950000580000021
13UkraineEUEEUHYB20235200000310000006.05202915070700000020000018
14UkraineEUEEUHYB20245400000330000006.15153015271750000018000018
15FranceEUWEUHYB20232700000175000006.55002816588450000015000019
16FranceEUWEUHYB20242750000182000006.64952916788460000013000019
17South_AfricaAFWAHYB20233000000125000004.24301813572250000010000019
18South_AfricaAFWAHYB20243050000128000004.2425191377226000009000018
19NigeriaAFWAOPV20235500000145000002.6740106025200000120000022
20NigeriaAFWAOPV20245600000150000002.7730116226220000110000022


3) CONSISTENCY CHECKS;

data maize_world;

  set maize_world;

  if abs(Yield_T_HA - (Production_Tonnes/Area_HA))>0.05 then 

    Yield_T_HA = round(Production_Tonnes/Area_HA,0.01);

  Export_Share = round(100*Export_Tonnes/max(1,Production_Tonnes),0.1);

  Net_Trade_Tonnes = Export_Tonnes - Import_Tonnes;

run;

proc print;run;

Output:

ObsCountryContRegSeed_TypeYearArea_HAProduction_TonnesYield_T_HARainfall_mmIrrigated_PctFertilizer_kg_haMechanization_IdxExport_TonnesImport_TonnesPrice_USD_TonExport_ShareNet_Trade_Tonnes
1United_StatesNANAMGMO20233700000039000000010.548022190926000000015000001815.458500000
2United_StatesNANAMGMO20243720000040000000010.847523192936200000012000001715.560800000
3ChinaASEAHHYB2023430000002900000006.7540411757880000003500000212.84500000
4ChinaASEAHHYB2024432000002980000006.9545421787990000003200000203.05800000
5BrazilSACSSGMO2023210000001350000006.45203416075280000009000001720.727100000
6BrazilSACSSGMO2024215000001420000006.65153516276300000007000001621.129300000
7IndiaASSAHHYB202310000000340000003.462045120557000002200000202.1-1500000
8IndiaASSAHHYB202410200000360000003.561546122569000002100000192.5-1200000
9ArgentinaSACSSGMO20237000000520000007.44702116580160000003000001730.815700000
10ArgentinaSACSSGMO20247200000540000007.54652216881170000002500001731.516750000
11MexicoNANAMHYB20237800000275000003.558033130659000006000000223.3-5100000
12MexicoNANAMHYB20247900000285000003.657534132669500005800000213.3-4850000
13UkraineEUEEUHYB20235200000310000006.0520291507070000002000001822.66800000
14UkraineEUEEUHYB20245400000330000006.1515301527175000001800001822.77320000
15FranceEUWEUHYB20232700000175000006.5500281658845000001500001925.74350000
16FranceEUWEUHYB20242750000182000006.6495291678846000001300001925.34470000
17South_AfricaAFWAHYB20233000000125000004.2430181357225000001000001920.02400000
18South_AfricaAFWAHYB20243050000128000004.242519137722600000900001820.32510000
19NigeriaAFWAOPV20235500000145000002.67401060252000001200000221.4-1000000
20NigeriaAFWAOPV20245600000150000002.77301162262200001100000221.5-880000


4) CONTENTS & QUICK PRINTS;

proc contents data=maize_world varnum; 

run;

Output:

The CONTENTS Procedure

Data Set NameWORK.MAIZE_WORLDObservations20
Member TypeDATAVariables17
EngineV9Indexes0
Created08/20/2025 17:56:17Observation Length144
Last Modified08/20/2025 17:56:17Deleted Observations0
Protection CompressedNO
Data Set Type SortedNO
Label   
Data RepresentationSOLARIS_X86_64, LINUX_X86_64, ALPHA_TRU64, LINUX_IA64  
Encodingutf-8 Unicode (UTF-8)  
Engine/Host Dependent Information
Data Set Page Size131072
Number of Data Set Pages1
First Data Page1
Max Obs per Page909
Obs in First Data Page20
Number of Data Set Repairs0
Filename/saswork/SAS_work1BE4000168AA_odaws01-apse1-2.oda.sas.com/SAS_work4666000168AA_odaws01-apse1-2.oda.sas.com/maize_world.sas7bdat
Release Created9.0401M8
Host CreatedLinux
Inode Number67108906
Access Permissionrw-r--r--
Owner Nameu63247146
File Size256KB
File Size (bytes)262144
Variables in Creation Order
#VariableTypeLenLabel
1CountryChar30 
2ContChar2Continent
3RegChar4Region
4Seed_TypeChar3Seed Category
5YearNum8 
6Area_HANum8Harvested Area (ha)
7Production_TonnesNum8Production (tonnes)
8Yield_T_HANum8Yield (tonnes/ha)
9Rainfall_mmNum8Growing-Season Rainfall (mm)
10Irrigated_PctNum8% Area Irrigated
11Fertilizer_kg_haNum8Fertilizer Use (kg/ha)
12Mechanization_IdxNum8Mechanization Index (0–100)
13Export_TonnesNum8Exports (tonnes)
14Import_TonnesNum8Imports (tonnes)
15Price_USD_TonNum8Farmgate Price (USD/ton)
16Export_ShareNum8 
17Net_Trade_TonnesNum8 

proc sort data=maize_world out=maize_sorted;

  by Year descending Production_Tonnes;

run;


proc print data=maize_sorted (obs=15) label;

  title "Top 15 Rows by Production (All Years)";

  var Year Country Cont Reg Production_Tonnes Yield_T_HA Export_Tonnes Import_Tonnes Net_Trade_Tonnes;

run;

Output:

Top 15 Rows by Production (All Years)

ObsYearCountryContinentRegionProduction (tonnes)Yield (tonnes/ha)Exports (tonnes)Imports (tonnes)Net_Trade_Tonnes
12023United_StatesNANAM39000000010.560000000150000058500000
22023ChinaASEAH2900000006.7800000035000004500000
32023BrazilSACSS1350000006.42800000090000027100000
42023ArgentinaSACSS520000007.41600000030000015700000
52023IndiaASSAH340000003.47000002200000-1500000
62023UkraineEUEEU310000006.070000002000006800000
72023MexicoNANAM275000003.59000006000000-5100000
82023FranceEUWEU175000006.545000001500004350000
92023NigeriaAFWA145000002.62000001200000-1000000
102023South_AfricaAFWA125000004.225000001000002400000
112024United_StatesNANAM40000000010.862000000120000060800000
122024ChinaASEAH2980000006.9900000032000005800000
132024BrazilSACSS1420000006.63000000070000029300000
142024ArgentinaSACSS540000007.51700000025000016750000
152024IndiaASSAH360000003.59000002100000-1200000

5) FREQUENCIES & DISTRIBUTIONS;

proc freq data=maize_world;

  tables Year*Cont Year*Seed_Type Seed_Type / nocum nopercent;

  format Cont $continent. Seed_Type $seedfmt.;

  title "Seed Types and Distribution by Continent/Year";

run;

Output:

Seed Types and Distribution by Continent/Year

The FREQ Procedure

Frequency
Row Pct
Col Pct
Table of Year by Cont
YearCont(Continent)
AfricaAsiaEuropeNorth AmericaSouth AmericaTotal
2023
2
20.00
50.00
2
20.00
50.00
2
20.00
50.00
2
20.00
50.00
2
20.00
50.00
10
 
 
2024
2
20.00
50.00
2
20.00
50.00
2
20.00
50.00
2
20.00
50.00
2
20.00
50.00
10
 
 
Total
4
4
4
4
4
20
Frequency
Row Pct
Col Pct
Table of Year by Seed_Type
YearSeed_Type(Seed Category)
GM/HybridHybridOpen-PollinatedTotal
2023
3
30.00
50.00
6
60.00
50.00
1
10.00
50.00
10
 
 
2024
3
30.00
50.00
6
60.00
50.00
1
10.00
50.00
10
 
 
Total
6
12
2
20
Seed Category
Seed_TypeFrequency
GM/Hybrid6
Hybrid12
Open-Pollinated2

proc univariate data=maize_world noprint;

  class Year;

  var Yield_T_HA Price_USD_Ton;

  histogram Yield_T_HA Price_USD_Ton;

  inset mean std min max / position=ne;

  title "Yield & Price Distribution by Year";

run;

Output:

Yield & Price Distribution by Year

The UNIVARIATE Procedure

Histogram for Yield_T_HA

Yield & Price Distribution by Year

The UNIVARIATE Procedure

Histogram for Price_USD_Ton

6) MEANS & SUMMARY;

proc means data=maize_world n mean std min p25 median p75 max maxdec=2;

  class Year Cont;

  var Area_HA Production_Tonnes Yield_T_HA Rainfall_mm Irrigated_Pct Fertilizer_kg_ha Mechanization_Idx Export_Tonnes Import_Tonnes Price_USD_Ton;

  types Year*Cont;

  title "Descriptive Statistics by Year × Continent";

run;

Output:

Descriptive Statistics by Year × Continent

The MEANS Procedure

YearContinentN ObsVariableLabelNMeanStd DevMinimum25th PctlMedian75th PctlMaximum
2023AF2
Area_HA
Production_Tonnes
Yield_T_HA
Rainfall_mm
Irrigated_Pct
Fertilizer_kg_ha
Mechanization_Idx
Export_Tonnes
Import_Tonnes
Price_USD_Ton
Harvested Area (ha)
Production (tonnes)
Yield (tonnes/ha)
Growing-Season Rainfall (mm)
% Area Irrigated
Fertilizer Use (kg/ha)
Mechanization Index (0–100)
Exports (tonnes)
Imports (tonnes)
Farmgate Price (USD/ton)
2
2
2
2
2
2
2
2
2
2
4250000.00
13500000.00
3.40
585.00
14.00
97.50
48.50
1350000.00
650000.00
20.50
1767766.95
1414213.56
1.13
219.20
5.66
53.03
33.23
1626345.60
777817.46
2.12
3000000.00
12500000.00
2.60
430.00
10.00
60.00
25.00
200000.00
100000.00
19.00
3000000.00
12500000.00
2.60
430.00
10.00
60.00
25.00
200000.00
100000.00
19.00
4250000.00
13500000.00
3.40
585.00
14.00
97.50
48.50
1350000.00
650000.00
20.50
5500000.00
14500000.00
4.20
740.00
18.00
135.00
72.00
2500000.00
1200000.00
22.00
5500000.00
14500000.00
4.20
740.00
18.00
135.00
72.00
2500000.00
1200000.00
22.00
 AS2
Area_HA
Production_Tonnes
Yield_T_HA
Rainfall_mm
Irrigated_Pct
Fertilizer_kg_ha
Mechanization_Idx
Export_Tonnes
Import_Tonnes
Price_USD_Ton
Harvested Area (ha)
Production (tonnes)
Yield (tonnes/ha)
Growing-Season Rainfall (mm)
% Area Irrigated
Fertilizer Use (kg/ha)
Mechanization Index (0–100)
Exports (tonnes)
Imports (tonnes)
Farmgate Price (USD/ton)
2
2
2
2
2
2
2
2
2
2
26500000.00
162000000.00
5.05
580.00
43.00
147.50
66.50
4350000.00
2850000.00
20.50
23334523.78
181019335.98
2.33
56.57
2.83
38.89
16.26
5161879.50
919238.82
0.71
10000000.00
34000000.00
3.40
540.00
41.00
120.00
55.00
700000.00
2200000.00
20.00
10000000.00
34000000.00
3.40
540.00
41.00
120.00
55.00
700000.00
2200000.00
20.00
26500000.00
162000000.00
5.05
580.00
43.00
147.50
66.50
4350000.00
2850000.00
20.50
43000000.00
290000000.00
6.70
620.00
45.00
175.00
78.00
8000000.00
3500000.00
21.00
43000000.00
290000000.00
6.70
620.00
45.00
175.00
78.00
8000000.00
3500000.00
21.00
 EU2
Area_HA
Production_Tonnes
Yield_T_HA
Rainfall_mm
Irrigated_Pct
Fertilizer_kg_ha
Mechanization_Idx
Export_Tonnes
Import_Tonnes
Price_USD_Ton
Harvested Area (ha)
Production (tonnes)
Yield (tonnes/ha)
Growing-Season Rainfall (mm)
% Area Irrigated
Fertilizer Use (kg/ha)
Mechanization Index (0–100)
Exports (tonnes)
Imports (tonnes)
Farmgate Price (USD/ton)
2
2
2
2
2
2
2
2
2
2
3950000.00
24250000.00
6.25
510.00
28.50
157.50
79.00
5750000.00
175000.00
18.50
1767766.95
9545941.55
0.35
14.14
0.71
10.61
12.73
1767766.95
35355.34
0.71
2700000.00
17500000.00
6.00
500.00
28.00
150.00
70.00
4500000.00
150000.00
18.00
2700000.00
17500000.00
6.00
500.00
28.00
150.00
70.00
4500000.00
150000.00
18.00
3950000.00
24250000.00
6.25
510.00
28.50
157.50
79.00
5750000.00
175000.00
18.50
5200000.00
31000000.00
6.50
520.00
29.00
165.00
88.00
7000000.00
200000.00
19.00
5200000.00
31000000.00
6.50
520.00
29.00
165.00
88.00
7000000.00
200000.00
19.00
 NA2
Area_HA
Production_Tonnes
Yield_T_HA
Rainfall_mm
Irrigated_Pct
Fertilizer_kg_ha
Mechanization_Idx
Export_Tonnes
Import_Tonnes
Price_USD_Ton
Harvested Area (ha)
Production (tonnes)
Yield (tonnes/ha)
Growing-Season Rainfall (mm)
% Area Irrigated
Fertilizer Use (kg/ha)
Mechanization Index (0–100)
Exports (tonnes)
Imports (tonnes)
Farmgate Price (USD/ton)
2
2
2
2
2
2
2
2
2
2
22400000.00
208750000.00
7.00
530.00
27.50
160.00
78.50
30450000.00
3750000.00
20.00
20647518.01
256326208.18
4.95
70.71
7.78
42.43
19.09
41790010.77
3181980.52
2.83
7800000.00
27500000.00
3.50
480.00
22.00
130.00
65.00
900000.00
1500000.00
18.00
7800000.00
27500000.00
3.50
480.00
22.00
130.00
65.00
900000.00
1500000.00
18.00
22400000.00
208750000.00
7.00
530.00
27.50
160.00
78.50
30450000.00
3750000.00
20.00
37000000.00
390000000.00
10.50
580.00
33.00
190.00
92.00
60000000.00
6000000.00
22.00
37000000.00
390000000.00
10.50
580.00
33.00
190.00
92.00
60000000.00
6000000.00
22.00
 SA2
Area_HA
Production_Tonnes
Yield_T_HA
Rainfall_mm
Irrigated_Pct
Fertilizer_kg_ha
Mechanization_Idx
Export_Tonnes
Import_Tonnes
Price_USD_Ton
Harvested Area (ha)
Production (tonnes)
Yield (tonnes/ha)
Growing-Season Rainfall (mm)
% Area Irrigated
Fertilizer Use (kg/ha)
Mechanization Index (0–100)
Exports (tonnes)
Imports (tonnes)
Farmgate Price (USD/ton)
2
2
2
2
2
2
2
2
2
2
14000000.00
93500000.00
6.90
495.00
27.50
162.50
77.50
22000000.00
600000.00
17.00
9899494.94
58689862.84
0.71
35.36
9.19
3.54
3.54
8485281.37
424264.07
0.00
7000000.00
52000000.00
6.40
470.00
21.00
160.00
75.00
16000000.00
300000.00
17.00
7000000.00
52000000.00
6.40
470.00
21.00
160.00
75.00
16000000.00
300000.00
17.00
14000000.00
93500000.00
6.90
495.00
27.50
162.50
77.50
22000000.00
600000.00
17.00
21000000.00
135000000.00
7.40
520.00
34.00
165.00
80.00
28000000.00
900000.00
17.00
21000000.00
135000000.00
7.40
520.00
34.00
165.00
80.00
28000000.00
900000.00
17.00
2024AF2
Area_HA
Production_Tonnes
Yield_T_HA
Rainfall_mm
Irrigated_Pct
Fertilizer_kg_ha
Mechanization_Idx
Export_Tonnes
Import_Tonnes
Price_USD_Ton
Harvested Area (ha)
Production (tonnes)
Yield (tonnes/ha)
Growing-Season Rainfall (mm)
% Area Irrigated
Fertilizer Use (kg/ha)
Mechanization Index (0–100)
Exports (tonnes)
Imports (tonnes)
Farmgate Price (USD/ton)
2
2
2
2
2
2
2
2
2
2
4325000.00
13900000.00
3.45
577.50
15.00
99.50
49.00
1410000.00
595000.00
20.00
1803122.29
1555634.92
1.06
215.67
5.66
53.03
32.53
1682914.14
714177.85
2.83
3050000.00
12800000.00
2.70
425.00
11.00
62.00
26.00
220000.00
90000.00
18.00
3050000.00
12800000.00
2.70
425.00
11.00
62.00
26.00
220000.00
90000.00
18.00
4325000.00
13900000.00
3.45
577.50
15.00
99.50
49.00
1410000.00
595000.00
20.00
5600000.00
15000000.00
4.20
730.00
19.00
137.00
72.00
2600000.00
1100000.00
22.00
5600000.00
15000000.00
4.20
730.00
19.00
137.00
72.00
2600000.00
1100000.00
22.00
 AS2
Area_HA
Production_Tonnes
Yield_T_HA
Rainfall_mm
Irrigated_Pct
Fertilizer_kg_ha
Mechanization_Idx
Export_Tonnes
Import_Tonnes
Price_USD_Ton
Harvested Area (ha)
Production (tonnes)
Yield (tonnes/ha)
Growing-Season Rainfall (mm)
% Area Irrigated
Fertilizer Use (kg/ha)
Mechanization Index (0–100)
Exports (tonnes)
Imports (tonnes)
Farmgate Price (USD/ton)
2
2
2
2
2
2
2
2
2
2
26700000.00
167000000.00
5.20
580.00
44.00
150.00
67.50
4950000.00
2650000.00
19.50
23334523.78
185261976.67
2.40
49.50
2.83
39.60
16.26
5727564.93
777817.46
0.71
10200000.00
36000000.00
3.50
545.00
42.00
122.00
56.00
900000.00
2100000.00
19.00
10200000.00
36000000.00
3.50
545.00
42.00
122.00
56.00
900000.00
2100000.00
19.00
26700000.00
167000000.00
5.20
580.00
44.00
150.00
67.50
4950000.00
2650000.00
19.50
43200000.00
298000000.00
6.90
615.00
46.00
178.00
79.00
9000000.00
3200000.00
20.00
43200000.00
298000000.00
6.90
615.00
46.00
178.00
79.00
9000000.00
3200000.00
20.00
 EU2
Area_HA
Production_Tonnes
Yield_T_HA
Rainfall_mm
Irrigated_Pct
Fertilizer_kg_ha
Mechanization_Idx
Export_Tonnes
Import_Tonnes
Price_USD_Ton
Harvested Area (ha)
Production (tonnes)
Yield (tonnes/ha)
Growing-Season Rainfall (mm)
% Area Irrigated
Fertilizer Use (kg/ha)
Mechanization Index (0–100)
Exports (tonnes)
Imports (tonnes)
Farmgate Price (USD/ton)
2
2
2
2
2
2
2
2
2
2
4075000.00
25600000.00
6.35
505.00
29.50
159.50
79.50
6050000.00
155000.00
18.50
1873832.97
10465180.36
0.35
14.14
0.71
10.61
12.02
2050609.67
35355.34
0.71
2750000.00
18200000.00
6.10
495.00
29.00
152.00
71.00
4600000.00
130000.00
18.00
2750000.00
18200000.00
6.10
495.00
29.00
152.00
71.00
4600000.00
130000.00
18.00
4075000.00
25600000.00
6.35
505.00
29.50
159.50
79.50
6050000.00
155000.00
18.50
5400000.00
33000000.00
6.60
515.00
30.00
167.00
88.00
7500000.00
180000.00
19.00
5400000.00
33000000.00
6.60
515.00
30.00
167.00
88.00
7500000.00
180000.00
19.00
 NA2
Area_HA
Production_Tonnes
Yield_T_HA
Rainfall_mm
Irrigated_Pct
Fertilizer_kg_ha
Mechanization_Idx
Export_Tonnes
Import_Tonnes
Price_USD_Ton
Harvested Area (ha)
Production (tonnes)
Yield (tonnes/ha)
Growing-Season Rainfall (mm)
% Area Irrigated
Fertilizer Use (kg/ha)
Mechanization Index (0–100)
Exports (tonnes)
Imports (tonnes)
Farmgate Price (USD/ton)
2
2
2
2
2
2
2
2
2
2
22550000.00
214250000.00
7.20
525.00
28.50
162.00
79.50
31475000.00
3500000.00
19.00
20718228.69
262690169.21
5.09
70.71
7.78
42.43
19.09
43168868.99
3252691.19
2.83
7900000.00
28500000.00
3.60
475.00
23.00
132.00
66.00
950000.00
1200000.00
17.00
7900000.00
28500000.00
3.60
475.00
23.00
132.00
66.00
950000.00
1200000.00
17.00
22550000.00
214250000.00
7.20
525.00
28.50
162.00
79.50
31475000.00
3500000.00
19.00
37200000.00
400000000.00
10.80
575.00
34.00
192.00
93.00
62000000.00
5800000.00
21.00
37200000.00
400000000.00
10.80
575.00
34.00
192.00
93.00
62000000.00
5800000.00
21.00
 SA2
Area_HA
Production_Tonnes
Yield_T_HA
Rainfall_mm
Irrigated_Pct
Fertilizer_kg_ha
Mechanization_Idx
Export_Tonnes
Import_Tonnes
Price_USD_Ton
Harvested Area (ha)
Production (tonnes)
Yield (tonnes/ha)
Growing-Season Rainfall (mm)
% Area Irrigated
Fertilizer Use (kg/ha)
Mechanization Index (0–100)
Exports (tonnes)
Imports (tonnes)
Farmgate Price (USD/ton)
2
2
2
2
2
2
2
2
2
2
14350000.00
98000000.00
7.05
490.00
28.50
165.00
78.50
23500000.00
475000.00
16.50
10111626.97
62225396.74
0.64
35.36
9.19
4.24
3.54
9192388.16
318198.05
0.71
7200000.00
54000000.00
6.60
465.00
22.00
162.00
76.00
17000000.00
250000.00
16.00
7200000.00
54000000.00
6.60
465.00
22.00
162.00
76.00
17000000.00
250000.00
16.00
14350000.00
98000000.00
7.05
490.00
28.50
165.00
78.50
23500000.00
475000.00
16.50
21500000.00
142000000.00
7.50
515.00
35.00
168.00
81.00
30000000.00
700000.00
17.00
21500000.00
142000000.00
7.50
515.00
35.00
168.00
81.00
30000000.00
700000.00
17.00

proc summary data=maize_world nway;

  class Year Cont;

  var Production_Tonnes Area_HA Export_Tonnes Import_Tonnes;

  output out=agg_continent (drop=_type_ _freq_)

    sum(Production_Tonnes)=Prod_Sum

    sum(Area_HA)=Area_Sum

    sum(Export_Tonnes)=Export_Sum

    sum(Import_Tonnes)=Import_Sum

    mean(Production_Tonnes)=Prod_Avg

    mean(Yield_T_HA)=Yield_Avg;

run;
proc print;run;

Output:

ObsYearContProd_SumArea_SumExport_SumImport_SumProd_AvgYield_Avg
12023AF27000000850000027000001300000135000003.40
22023AS32400000053000000870000057000001620000005.05
32023EU48500000790000011500000350000242500006.25
42023NA417500000448000006090000075000002087500007.00
52023SA18700000028000000440000001200000935000006.90
62024AF27800000865000028200001190000139000003.45
72024AS33400000053400000990000053000001670000005.20
82024EU51200000815000012100000310000256000006.35
92024NA428500000451000006295000070000002142500007.20
102024SA1960000002870000047000000950000980000007.05


7) TABULATE & REPORT;

proc tabulate data=maize_world format=comma12.;

  class Cont Year;

  var Production_Tonnes Area_HA Yield_T_HA Net_Trade_Tonnes;

  table Cont='Continent' all,

        Year*(Production_Tonnes*sum Area_HA*sum Yield_T_HA*mean Net_Trade_Tonnes*sum) / misstext='0';

  keylabel sum='Sum' mean='Average';

  title "Tabulated View: Production/Area/Yield/Net Trade by Continent & Year";

run;

Output:

Tabulated View: Production/Area/Yield/Net Trade by Continent & Year

 Year
20232024
Production (tonnes)Harvested Area (ha)Yield (tonnes/ha)Net_Trade_TonnesProduction (tonnes)Harvested Area (ha)Yield (tonnes/ha)Net_Trade_Tonnes
SumSumAverageSumSumSumAverageSum
Continent27,000,0008,500,00031,400,00027,800,0008,650,00031,630,000
AF
AS324,000,00053,000,00053,000,000334,000,00053,400,00054,600,000
EU48,500,0007,900,000611,150,00051,200,0008,150,000611,790,000
NA417,500,00044,800,000753,400,000428,500,00045,100,000755,950,000
SA187,000,00028,000,000742,800,000196,000,00028,700,000746,050,000
All1004000000142,200,0006111,750,0001037500000144,000,0006120,020,000

proc report data=maize_world nowd;

  columns Year Cont Country Area_HA Production_Tonnes Yield_T_HA Export_Share Price_USD_Ton;

  define Year / group;

  define Cont / group format=$continent.;

  define Country / display;

  define Area_HA / analysis sum format=comma12.;

  define Production_Tonnes / analysis sum format=comma12.;

  define Yield_T_HA / analysis mean format=8.2 'Avg Yield';

  define Export_Share / analysis mean format=6.1 'Avg Export %';

  define Price_USD_Ton / analysis mean format=8.2 'Avg Price';

  rbreak after / summarize dol skip;

  title "Report: Country Contribution and Averages by Year & Continent";

run;

Output:

Report: Country Contribution and Averages by Year & Continent

YearContinentCountryHarvested Area (ha)Production (tonnes)Avg YieldAvg Export %Avg Price
2023AfricaSouth_Africa3,000,00012,500,0004.2020.019.00
  Nigeria5,500,00014,500,0002.601.422.00
 AsiaChina43,000,000290,000,0006.702.821.00
  India10,000,00034,000,0003.402.120.00
 EuropeUkraine5,200,00031,000,0006.0022.618.00
  France2,700,00017,500,0006.5025.719.00
 North AmericaUnited_States37,000,000390,000,00010.5015.418.00
  Mexico7,800,00027,500,0003.503.322.00
 South AmericaBrazil21,000,000135,000,0006.4020.717.00
  Argentina7,000,00052,000,0007.4030.817.00
2024AfricaSouth_Africa3,050,00012,800,0004.2020.318.00
  Nigeria5,600,00015,000,0002.701.522.00
 AsiaChina43,200,000298,000,0006.903.020.00
  India10,200,00036,000,0003.502.519.00
 EuropeUkraine5,400,00033,000,0006.1022.718.00
  France2,750,00018,200,0006.6025.319.00
 North AmericaUnited_States37,200,000400,000,00010.8015.517.00
  Mexico7,900,00028,500,0003.603.321.00
 South AmericaBrazil21,500,000142,000,0006.6021.116.00
  Argentina7,200,00054,000,0007.5031.517.00
   286,200,00020415000005.7814.619.00

8) TRANSPOSE: country-by-year pivot for yields;

proc sort data=maize_world out=for_transpose;

  by Country Year;

run;


proc transpose data=for_transpose out=yield_pivot prefix=Y_;

  by Country;

  id Year;

  var Yield_T_HA;

run;

proc print;run;

Output:

ObsCountry_NAME__LABEL_Y_2023Y_2024
1ArgentinaYield_T_HAYield (tonnes/ha)7.47.5
2BrazilYield_T_HAYield (tonnes/ha)6.46.6
3ChinaYield_T_HAYield (tonnes/ha)6.76.9
4FranceYield_T_HAYield (tonnes/ha)6.56.6
5IndiaYield_T_HAYield (tonnes/ha)3.43.5
6MexicoYield_T_HAYield (tonnes/ha)3.53.6
7NigeriaYield_T_HAYield (tonnes/ha)2.62.7
8South_AfricaYield_T_HAYield (tonnes/ha)4.24.2
9UkraineYield_T_HAYield (tonnes/ha)6.06.1
10United_StatesYield_T_HAYield (tonnes/ha)10.510.8


9) PROC SQL: rankings, joins, derived insights;

proc sql;

  create table country_two_years as

  select a.Country, a.Cont, a.Reg, 

         a.Production_Tonnes as Prod_2023,

         b.Production_Tonnes as Prod_2024,

         a.Yield_T_HA as Yield_2023,

         b.Yield_T_HA as Yield_2024,

         case when a.Production_Tonnes>0 

              then (b.Production_Tonnes - a.Production_Tonnes)/a.Production_Tonnes

              else . end as Prod_Growth_Rate,

         case when a.Yield_T_HA>0 

              then (b.Yield_T_HA - a.Yield_T_HA)/a.Yield_T_HA

              else . end as Yield_Growth_Rate

  from maize_world as a

  inner join maize_world as b

    on a.Country=b.Country and a.Cont=b.Cont and a.Reg=b.Reg

   and a.Year=2023 and b.Year=2024

  order by Prod_Growth_Rate desc;

quit;

proc print;run;

Output:

ObsCountryContRegProd_2023Prod_2024Yield_2023Yield_2024Prod_Growth_RateYield_Growth_Rate
1UkraineEUEEU31000000330000006.06.10.0645160.016667
2IndiaASSAH34000000360000003.43.50.0588240.029412
3BrazilSACSS1350000001420000006.46.60.0518520.031250
4FranceEUWEU17500000182000006.56.60.0400000.015385
5ArgentinaSACSS52000000540000007.47.50.0384620.013514
6MexicoNANAM27500000285000003.53.60.0363640.028571
7NigeriaAFWA14500000150000002.62.70.0344830.038462
8ChinaASEAH2900000002980000006.76.90.0275860.029851
9United_StatesNANAM39000000040000000010.510.80.0256410.028571
10South_AfricaAFWA12500000128000004.24.20.0240000.000000


10) RANK: who leads on yield and exports in 2024;

proc sort data=maize_world(where=(Year=2024)) out=yr2024;

  by descending Yield_T_HA;

run;


proc rank data=yr2024 out=ranks_2024 ties=low descending;

  var Yield_T_HA Export_Tonnes;

  ranks Yield_Rank Export_Rank;

run;

Output:

ObsCountryContRegSeed_TypeYearArea_HAProduction_TonnesYield_T_HARainfall_mmIrrigated_PctFertilizer_kg_haMechanization_IdxExport_TonnesImport_TonnesPrice_USD_TonExport_ShareNet_Trade_TonnesYield_RankExport_Rank
1United_StatesNANAMGMO20243720000040000000010.847523192936200000012000001715.56080000011
2ArgentinaSACSSGMO20247200000540000007.54652216881170000002500001731.51675000023
3ChinaASEAHHYB2024432000002980000006.9545421787990000003200000203.0580000034
4BrazilSACSSGMO2024215000001420000006.65153516276300000007000001621.12930000042
5FranceEUWEUHYB20242750000182000006.6495291678846000001300001925.3447000046
6UkraineEUEEUHYB20245400000330000006.1515301527175000001800001822.7732000065
7South_AfricaAFWAHYB20243050000128000004.242519137722600000900001820.3251000077
8MexicoNANAMHYB20247900000285000003.657534132669500005800000213.3-485000088
9IndiaASSAHHYB202410200000360000003.561546122569000002100000192.5-120000099
10NigeriaAFWAOPV20245600000150000002.77301162262200001100000221.5-8800001010


11) SGPLOT: simple visuals;

ods graphics on;


proc sgplot data=maize_world(where=(Year=2024));

  vbar Cont / response=Production_Tonnes stat=sum;

  yaxis label="Total Production (tonnes)";

  xaxis label="Continent";

  title "2024: Total Maize Production by Continent";

run;


proc sgplot data=maize_world(where=(Year=2024));

  scatter x=Yield_T_HA y=Price_USD_Ton / datalabel=Country;

  xaxis label="Yield (t/ha)";

  yaxis label="Farmgate Price (USD/ton)";

  title "2024: Yield vs Price by Country";

run;


ods graphics off;

Output:

The SGPlot Procedure

The SGPlot Procedure


12) MACROS: reusable analytics;

%macro continent_dashboard(yr);

  proc summary data=maize_world(where=(Year=&yr)) nway;

    class Cont;

    var Production_Tonnes Area_HA Export_Tonnes Import_Tonnes Yield_T_HA Irrigated_Pct Fertilizer_kg_ha;

    output out=cont_dash_&yr(drop=_:) 

      sum(Production_Tonnes)=Prod_Sum

      sum(Area_HA)=Area_Sum

      sum(Export_Tonnes)=Export_Sum

      sum(Import_Tonnes)=Import_Sum

      mean(Yield_T_HA)=Yield_Avg

      mean(Irrigated_Pct)=Irrig_Avg

      mean(Fertilizer_kg_ha)=Fert_Avg;

  run;


  proc report data=cont_dash_&yr nowd;

    columns Cont Prod_Sum Area_Sum Yield_Avg Export_Sum Import_Sum Irrig_Avg Fert_Avg;

    define Cont / group format=$continent.;

    define Prod_Sum / analysis sum format=comma12.;

    define Area_Sum / analysis sum format=comma12.;

    define Yield_Avg / analysis mean format=8.2 'Avg Yield';

    define Export_Sum / analysis sum format=comma12.;

    define Import_Sum / analysis sum format=comma12.;

    define Irrig_Avg / analysis mean format=6.1 'Avg Irrig %';

    define Fert_Avg / analysis mean format=8.1 'Avg Fert kg/ha';

    title "Continent Dashboard — &yr";

  run;

%mend;


%continent_dashboard(2023);

Output:

Continent Dashboard — 2023

ContinentProduction (tonnes)Harvested Area (ha)Avg YieldExports (tonnes)Imports (tonnes)Avg Irrig %Avg Fert kg
ha
Africa27,000,0008,500,0003.402,700,0001,300,00014.097.5
Asia324,000,00053,000,0005.058,700,0005,700,00043.0147.5
Europe48,500,0007,900,0006.2511,500,000350,00028.5157.5
North America417,500,00044,800,0007.0060,900,0007,500,00027.5160.0
South America187,000,00028,000,0006.9044,000,0001,200,00027.5162.5

%continent_dashboard(2024);

Output:

Continent Dashboard — 2024

ContinentProduction (tonnes)Harvested Area (ha)Avg YieldExports (tonnes)Imports (tonnes)Avg Irrig %Avg Fert kg
ha
Africa27,800,0008,650,0003.452,820,0001,190,00015.099.5
Asia334,000,00053,400,0005.209,900,0005,300,00044.0150.0
Europe51,200,0008,150,0006.3512,100,000310,00029.5159.5
North America428,500,00045,100,0007.2062,950,0007,000,00028.5162.0
South America196,000,00028,700,0007.0547,000,000950,00028.5165.0

%macro topN(metric=Production_Tonnes, yr=2024, n=10);

  proc sort data=maize_world(where=(Year=&yr)) out=_tmp;

    by descending &metric;

  run;

  proc print data=_tmp(obs=&n) label;

    var Country Cont Reg &metric Yield_T_HA Area_HA Export_Tonnes Import_Tonnes;

    title "Top &n by &metric in &yr";

  run;

  proc datasets nolist; delete _tmp; quit;

%mend;


%topN(metric=Yield_T_HA, yr=2024, n=8);

Output:

Top 8 by Yield_T_HA in 2024

ObsCountryContinentRegionYield (tonnes/ha)Yield (tonnes/ha)Harvested Area (ha)Exports (tonnes)Imports (tonnes)
1United_StatesNANAM10.810.837200000620000001200000
2ArgentinaSACSS7.57.5720000017000000250000
3ChinaASEAH6.96.94320000090000003200000
4BrazilSACSS6.66.62150000030000000700000
5FranceEUWEU6.66.627500004600000130000
6UkraineEUEEU6.16.154000007500000180000
7South_AfricaAFWA4.24.23050000260000090000
8MexicoNANAM3.63.679000009500005800000

%topN(metric=Export_Tonnes, yr=2024, n=8);

Output:

Top 8 by Export_Tonnes in 2024

ObsCountryContinentRegionExports (tonnes)Yield (tonnes/ha)Harvested Area (ha)Exports (tonnes)Imports (tonnes)
1United_StatesNANAM6200000010.837200000620000001200000
2BrazilSACSS300000006.62150000030000000700000
3ArgentinaSACSS170000007.5720000017000000250000
4ChinaASEAH90000006.94320000090000003200000
5UkraineEUEEU75000006.154000007500000180000
6FranceEUWEU46000006.627500004600000130000
7South_AfricaAFWA26000004.23050000260000090000
8MexicoNANAM9500003.679000009500005800000

%macro qc_yield(threshold=2);

  data qc_report;

    set maize_world;

    Yield_Check = abs(Yield_T_HA - (Production_Tonnes/max(1,Area_HA)));

    if Yield_Check>&threshold then Flag='Y';

    else Flag='N';

  run;


  proc freq data=qc_report;

    tables Year*Flag / nopercent norow nocol;

    title "QC: Yield Consistency Flags (> &threshold t/ha difference)";

  run;


  proc print data=qc_report(where=(Flag='Y'));

    var Year Country Area_HA Production_Tonnes Yield_T_HA Yield_Check;

    title "QC Details: Rows Triggering Yield Consistency Flag";

  run;

%mend;


%qc_yield(threshold=0.5);

Output:

QC: Yield Consistency Flags (> 0.5 t/ha difference)

The FREQ Procedure

Frequency
Table of Year by Flag
YearFlag
NTotal
2023
10
10
2024
10
10
Total
20
20

To Visit My Previous E-Commerce Dataset:Click Here
To Visit My Previous Length,Input,Retain Statements:Click Here
To Visit My Previous Urban Traffic Dataset:Click Here
To Visit My Previous Home Energy Consumption Dataset: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

No comments:

Post a Comment