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:
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:
| Obs | Country | Cont | Reg | Seed_Type | Year | Area_HA | Production_Tonnes | Yield_T_HA | Rainfall_mm | Irrigated_Pct | Fertilizer_kg_ha | Mechanization_Idx | Export_Tonnes | Import_Tonnes | Price_USD_Ton |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | United_States | NA | NAM | GMO | 2023 | 37000000 | 390000000 | 10.5 | 480 | 22 | 190 | 92 | 60000000 | 1500000 | 18 |
| 2 | United_States | NA | NAM | GMO | 2024 | 37200000 | 400000000 | 10.8 | 475 | 23 | 192 | 93 | 62000000 | 1200000 | 17 |
| 3 | China | AS | EAH | HYB | 2023 | 43000000 | 290000000 | 6.7 | 540 | 41 | 175 | 78 | 8000000 | 3500000 | 21 |
| 4 | China | AS | EAH | HYB | 2024 | 43200000 | 298000000 | 6.9 | 545 | 42 | 178 | 79 | 9000000 | 3200000 | 20 |
| 5 | Brazil | SA | CSS | GMO | 2023 | 21000000 | 135000000 | 6.4 | 520 | 34 | 160 | 75 | 28000000 | 900000 | 17 |
| 6 | Brazil | SA | CSS | GMO | 2024 | 21500000 | 142000000 | 6.6 | 515 | 35 | 162 | 76 | 30000000 | 700000 | 16 |
| 7 | India | AS | SAH | HYB | 2023 | 10000000 | 34000000 | 3.4 | 620 | 45 | 120 | 55 | 700000 | 2200000 | 20 |
| 8 | India | AS | SAH | HYB | 2024 | 10200000 | 36000000 | 3.5 | 615 | 46 | 122 | 56 | 900000 | 2100000 | 19 |
| 9 | Argentina | SA | CSS | GMO | 2023 | 7000000 | 52000000 | 7.4 | 470 | 21 | 165 | 80 | 16000000 | 300000 | 17 |
| 10 | Argentina | SA | CSS | GMO | 2024 | 7200000 | 54000000 | 7.5 | 465 | 22 | 168 | 81 | 17000000 | 250000 | 17 |
| 11 | Mexico | NA | NAM | HYB | 2023 | 7800000 | 27500000 | 3.5 | 580 | 33 | 130 | 65 | 900000 | 6000000 | 22 |
| 12 | Mexico | NA | NAM | HYB | 2024 | 7900000 | 28500000 | 3.6 | 575 | 34 | 132 | 66 | 950000 | 5800000 | 21 |
| 13 | Ukraine | EU | EEU | HYB | 2023 | 5200000 | 31000000 | 6.0 | 520 | 29 | 150 | 70 | 7000000 | 200000 | 18 |
| 14 | Ukraine | EU | EEU | HYB | 2024 | 5400000 | 33000000 | 6.1 | 515 | 30 | 152 | 71 | 7500000 | 180000 | 18 |
| 15 | France | EU | WEU | HYB | 2023 | 2700000 | 17500000 | 6.5 | 500 | 28 | 165 | 88 | 4500000 | 150000 | 19 |
| 16 | France | EU | WEU | HYB | 2024 | 2750000 | 18200000 | 6.6 | 495 | 29 | 167 | 88 | 4600000 | 130000 | 19 |
| 17 | South_Africa | AF | WA | HYB | 2023 | 3000000 | 12500000 | 4.2 | 430 | 18 | 135 | 72 | 2500000 | 100000 | 19 |
| 18 | South_Africa | AF | WA | HYB | 2024 | 3050000 | 12800000 | 4.2 | 425 | 19 | 137 | 72 | 2600000 | 90000 | 18 |
| 19 | Nigeria | AF | WA | OPV | 2023 | 5500000 | 14500000 | 2.6 | 740 | 10 | 60 | 25 | 200000 | 1200000 | 22 |
| 20 | Nigeria | AF | WA | OPV | 2024 | 5600000 | 15000000 | 2.7 | 730 | 11 | 62 | 26 | 220000 | 1100000 | 22 |
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:
| Obs | Country | Cont | Reg | Seed_Type | Year | Area_HA | Production_Tonnes | Yield_T_HA | Rainfall_mm | Irrigated_Pct | Fertilizer_kg_ha | Mechanization_Idx | Export_Tonnes | Import_Tonnes | Price_USD_Ton | Export_Share | Net_Trade_Tonnes |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | United_States | NA | NAM | GMO | 2023 | 37000000 | 390000000 | 10.5 | 480 | 22 | 190 | 92 | 60000000 | 1500000 | 18 | 15.4 | 58500000 |
| 2 | United_States | NA | NAM | GMO | 2024 | 37200000 | 400000000 | 10.8 | 475 | 23 | 192 | 93 | 62000000 | 1200000 | 17 | 15.5 | 60800000 |
| 3 | China | AS | EAH | HYB | 2023 | 43000000 | 290000000 | 6.7 | 540 | 41 | 175 | 78 | 8000000 | 3500000 | 21 | 2.8 | 4500000 |
| 4 | China | AS | EAH | HYB | 2024 | 43200000 | 298000000 | 6.9 | 545 | 42 | 178 | 79 | 9000000 | 3200000 | 20 | 3.0 | 5800000 |
| 5 | Brazil | SA | CSS | GMO | 2023 | 21000000 | 135000000 | 6.4 | 520 | 34 | 160 | 75 | 28000000 | 900000 | 17 | 20.7 | 27100000 |
| 6 | Brazil | SA | CSS | GMO | 2024 | 21500000 | 142000000 | 6.6 | 515 | 35 | 162 | 76 | 30000000 | 700000 | 16 | 21.1 | 29300000 |
| 7 | India | AS | SAH | HYB | 2023 | 10000000 | 34000000 | 3.4 | 620 | 45 | 120 | 55 | 700000 | 2200000 | 20 | 2.1 | -1500000 |
| 8 | India | AS | SAH | HYB | 2024 | 10200000 | 36000000 | 3.5 | 615 | 46 | 122 | 56 | 900000 | 2100000 | 19 | 2.5 | -1200000 |
| 9 | Argentina | SA | CSS | GMO | 2023 | 7000000 | 52000000 | 7.4 | 470 | 21 | 165 | 80 | 16000000 | 300000 | 17 | 30.8 | 15700000 |
| 10 | Argentina | SA | CSS | GMO | 2024 | 7200000 | 54000000 | 7.5 | 465 | 22 | 168 | 81 | 17000000 | 250000 | 17 | 31.5 | 16750000 |
| 11 | Mexico | NA | NAM | HYB | 2023 | 7800000 | 27500000 | 3.5 | 580 | 33 | 130 | 65 | 900000 | 6000000 | 22 | 3.3 | -5100000 |
| 12 | Mexico | NA | NAM | HYB | 2024 | 7900000 | 28500000 | 3.6 | 575 | 34 | 132 | 66 | 950000 | 5800000 | 21 | 3.3 | -4850000 |
| 13 | Ukraine | EU | EEU | HYB | 2023 | 5200000 | 31000000 | 6.0 | 520 | 29 | 150 | 70 | 7000000 | 200000 | 18 | 22.6 | 6800000 |
| 14 | Ukraine | EU | EEU | HYB | 2024 | 5400000 | 33000000 | 6.1 | 515 | 30 | 152 | 71 | 7500000 | 180000 | 18 | 22.7 | 7320000 |
| 15 | France | EU | WEU | HYB | 2023 | 2700000 | 17500000 | 6.5 | 500 | 28 | 165 | 88 | 4500000 | 150000 | 19 | 25.7 | 4350000 |
| 16 | France | EU | WEU | HYB | 2024 | 2750000 | 18200000 | 6.6 | 495 | 29 | 167 | 88 | 4600000 | 130000 | 19 | 25.3 | 4470000 |
| 17 | South_Africa | AF | WA | HYB | 2023 | 3000000 | 12500000 | 4.2 | 430 | 18 | 135 | 72 | 2500000 | 100000 | 19 | 20.0 | 2400000 |
| 18 | South_Africa | AF | WA | HYB | 2024 | 3050000 | 12800000 | 4.2 | 425 | 19 | 137 | 72 | 2600000 | 90000 | 18 | 20.3 | 2510000 |
| 19 | Nigeria | AF | WA | OPV | 2023 | 5500000 | 14500000 | 2.6 | 740 | 10 | 60 | 25 | 200000 | 1200000 | 22 | 1.4 | -1000000 |
| 20 | Nigeria | AF | WA | OPV | 2024 | 5600000 | 15000000 | 2.7 | 730 | 11 | 62 | 26 | 220000 | 1100000 | 22 | 1.5 | -880000 |
4) CONTENTS & QUICK PRINTS;
proc contents data=maize_world varnum;
run;
Output:
The CONTENTS Procedure
| Data Set Name | WORK.MAIZE_WORLD | Observations | 20 |
|---|---|---|---|
| Member Type | DATA | Variables | 17 |
| Engine | V9 | Indexes | 0 |
| Created | 08/20/2025 17:56:17 | Observation Length | 144 |
| Last Modified | 08/20/2025 17:56:17 | 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 | 909 |
| Obs in First Data Page | 20 |
| Number of Data Set Repairs | 0 |
| Filename | /saswork/SAS_work1BE4000168AA_odaws01-apse1-2.oda.sas.com/SAS_work4666000168AA_odaws01-apse1-2.oda.sas.com/maize_world.sas7bdat |
| Release Created | 9.0401M8 |
| Host Created | Linux |
| Inode Number | 67108906 |
| Access Permission | rw-r--r-- |
| Owner Name | u63247146 |
| File Size | 256KB |
| File Size (bytes) | 262144 |
| Variables in Creation Order | ||||
|---|---|---|---|---|
| # | Variable | Type | Len | Label |
| 1 | Country | Char | 30 | |
| 2 | Cont | Char | 2 | Continent |
| 3 | Reg | Char | 4 | Region |
| 4 | Seed_Type | Char | 3 | Seed Category |
| 5 | Year | Num | 8 | |
| 6 | Area_HA | Num | 8 | Harvested Area (ha) |
| 7 | Production_Tonnes | Num | 8 | Production (tonnes) |
| 8 | Yield_T_HA | Num | 8 | Yield (tonnes/ha) |
| 9 | Rainfall_mm | Num | 8 | Growing-Season Rainfall (mm) |
| 10 | Irrigated_Pct | Num | 8 | % Area Irrigated |
| 11 | Fertilizer_kg_ha | Num | 8 | Fertilizer Use (kg/ha) |
| 12 | Mechanization_Idx | Num | 8 | Mechanization Index (0–100) |
| 13 | Export_Tonnes | Num | 8 | Exports (tonnes) |
| 14 | Import_Tonnes | Num | 8 | Imports (tonnes) |
| 15 | Price_USD_Ton | Num | 8 | Farmgate Price (USD/ton) |
| 16 | Export_Share | Num | 8 | |
| 17 | Net_Trade_Tonnes | Num | 8 | |
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:
| Obs | Year | Country | Continent | Region | Production (tonnes) | Yield (tonnes/ha) | Exports (tonnes) | Imports (tonnes) | Net_Trade_Tonnes |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 2023 | United_States | NA | NAM | 390000000 | 10.5 | 60000000 | 1500000 | 58500000 |
| 2 | 2023 | China | AS | EAH | 290000000 | 6.7 | 8000000 | 3500000 | 4500000 |
| 3 | 2023 | Brazil | SA | CSS | 135000000 | 6.4 | 28000000 | 900000 | 27100000 |
| 4 | 2023 | Argentina | SA | CSS | 52000000 | 7.4 | 16000000 | 300000 | 15700000 |
| 5 | 2023 | India | AS | SAH | 34000000 | 3.4 | 700000 | 2200000 | -1500000 |
| 6 | 2023 | Ukraine | EU | EEU | 31000000 | 6.0 | 7000000 | 200000 | 6800000 |
| 7 | 2023 | Mexico | NA | NAM | 27500000 | 3.5 | 900000 | 6000000 | -5100000 |
| 8 | 2023 | France | EU | WEU | 17500000 | 6.5 | 4500000 | 150000 | 4350000 |
| 9 | 2023 | Nigeria | AF | WA | 14500000 | 2.6 | 200000 | 1200000 | -1000000 |
| 10 | 2023 | South_Africa | AF | WA | 12500000 | 4.2 | 2500000 | 100000 | 2400000 |
| 11 | 2024 | United_States | NA | NAM | 400000000 | 10.8 | 62000000 | 1200000 | 60800000 |
| 12 | 2024 | China | AS | EAH | 298000000 | 6.9 | 9000000 | 3200000 | 5800000 |
| 13 | 2024 | Brazil | SA | CSS | 142000000 | 6.6 | 30000000 | 700000 | 29300000 |
| 14 | 2024 | Argentina | SA | CSS | 54000000 | 7.5 | 17000000 | 250000 | 16750000 |
| 15 | 2024 | India | AS | SAH | 36000000 | 3.5 | 900000 | 2100000 | -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:
The FREQ Procedure
|
| ||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||
| Seed Category | |
|---|---|
| Seed_Type | Frequency |
| GM/Hybrid | 6 |
| Hybrid | 12 |
| Open-Pollinated | 2 |
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:
The UNIVARIATE Procedure
The UNIVARIATE Procedure
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:
The MEANS Procedure
| Year | Continent | N Obs | Variable | Label | N | Mean | Std Dev | Minimum | 25th Pctl | Median | 75th Pctl | Maximum |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2023 | AF | 2 | 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 |
| AS | 2 | 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 | |
| EU | 2 | 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 | |
| NA | 2 | 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 | |
| SA | 2 | 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 | |
| 2024 | AF | 2 | 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 |
| AS | 2 | 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 | |
| EU | 2 | 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 | |
| NA | 2 | 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 | |
| SA | 2 | 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:
| Obs | Year | Cont | Prod_Sum | Area_Sum | Export_Sum | Import_Sum | Prod_Avg | Yield_Avg |
|---|---|---|---|---|---|---|---|---|
| 1 | 2023 | AF | 27000000 | 8500000 | 2700000 | 1300000 | 13500000 | 3.40 |
| 2 | 2023 | AS | 324000000 | 53000000 | 8700000 | 5700000 | 162000000 | 5.05 |
| 3 | 2023 | EU | 48500000 | 7900000 | 11500000 | 350000 | 24250000 | 6.25 |
| 4 | 2023 | NA | 417500000 | 44800000 | 60900000 | 7500000 | 208750000 | 7.00 |
| 5 | 2023 | SA | 187000000 | 28000000 | 44000000 | 1200000 | 93500000 | 6.90 |
| 6 | 2024 | AF | 27800000 | 8650000 | 2820000 | 1190000 | 13900000 | 3.45 |
| 7 | 2024 | AS | 334000000 | 53400000 | 9900000 | 5300000 | 167000000 | 5.20 |
| 8 | 2024 | EU | 51200000 | 8150000 | 12100000 | 310000 | 25600000 | 6.35 |
| 9 | 2024 | NA | 428500000 | 45100000 | 62950000 | 7000000 | 214250000 | 7.20 |
| 10 | 2024 | SA | 196000000 | 28700000 | 47000000 | 950000 | 98000000 | 7.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:
| Year | ||||||||
|---|---|---|---|---|---|---|---|---|
| 2023 | 2024 | |||||||
| Production (tonnes) | Harvested Area (ha) | Yield (tonnes/ha) | Net_Trade_Tonnes | Production (tonnes) | Harvested Area (ha) | Yield (tonnes/ha) | Net_Trade_Tonnes | |
| Sum | Sum | Average | Sum | Sum | Sum | Average | Sum | |
| Continent | 27,000,000 | 8,500,000 | 3 | 1,400,000 | 27,800,000 | 8,650,000 | 3 | 1,630,000 |
| AF | ||||||||
| AS | 324,000,000 | 53,000,000 | 5 | 3,000,000 | 334,000,000 | 53,400,000 | 5 | 4,600,000 |
| EU | 48,500,000 | 7,900,000 | 6 | 11,150,000 | 51,200,000 | 8,150,000 | 6 | 11,790,000 |
| NA | 417,500,000 | 44,800,000 | 7 | 53,400,000 | 428,500,000 | 45,100,000 | 7 | 55,950,000 |
| SA | 187,000,000 | 28,000,000 | 7 | 42,800,000 | 196,000,000 | 28,700,000 | 7 | 46,050,000 |
| All | 1004000000 | 142,200,000 | 6 | 111,750,000 | 1037500000 | 144,000,000 | 6 | 120,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:
| Year | Continent | Country | Harvested Area (ha) | Production (tonnes) | Avg Yield | Avg Export % | Avg Price |
|---|---|---|---|---|---|---|---|
| 2023 | Africa | South_Africa | 3,000,000 | 12,500,000 | 4.20 | 20.0 | 19.00 |
| Nigeria | 5,500,000 | 14,500,000 | 2.60 | 1.4 | 22.00 | ||
| Asia | China | 43,000,000 | 290,000,000 | 6.70 | 2.8 | 21.00 | |
| India | 10,000,000 | 34,000,000 | 3.40 | 2.1 | 20.00 | ||
| Europe | Ukraine | 5,200,000 | 31,000,000 | 6.00 | 22.6 | 18.00 | |
| France | 2,700,000 | 17,500,000 | 6.50 | 25.7 | 19.00 | ||
| North America | United_States | 37,000,000 | 390,000,000 | 10.50 | 15.4 | 18.00 | |
| Mexico | 7,800,000 | 27,500,000 | 3.50 | 3.3 | 22.00 | ||
| South America | Brazil | 21,000,000 | 135,000,000 | 6.40 | 20.7 | 17.00 | |
| Argentina | 7,000,000 | 52,000,000 | 7.40 | 30.8 | 17.00 | ||
| 2024 | Africa | South_Africa | 3,050,000 | 12,800,000 | 4.20 | 20.3 | 18.00 |
| Nigeria | 5,600,000 | 15,000,000 | 2.70 | 1.5 | 22.00 | ||
| Asia | China | 43,200,000 | 298,000,000 | 6.90 | 3.0 | 20.00 | |
| India | 10,200,000 | 36,000,000 | 3.50 | 2.5 | 19.00 | ||
| Europe | Ukraine | 5,400,000 | 33,000,000 | 6.10 | 22.7 | 18.00 | |
| France | 2,750,000 | 18,200,000 | 6.60 | 25.3 | 19.00 | ||
| North America | United_States | 37,200,000 | 400,000,000 | 10.80 | 15.5 | 17.00 | |
| Mexico | 7,900,000 | 28,500,000 | 3.60 | 3.3 | 21.00 | ||
| South America | Brazil | 21,500,000 | 142,000,000 | 6.60 | 21.1 | 16.00 | |
| Argentina | 7,200,000 | 54,000,000 | 7.50 | 31.5 | 17.00 | ||
| 286,200,000 | 2041500000 | 5.78 | 14.6 | 19.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:
| Obs | Country | _NAME_ | _LABEL_ | Y_2023 | Y_2024 |
|---|---|---|---|---|---|
| 1 | Argentina | Yield_T_HA | Yield (tonnes/ha) | 7.4 | 7.5 |
| 2 | Brazil | Yield_T_HA | Yield (tonnes/ha) | 6.4 | 6.6 |
| 3 | China | Yield_T_HA | Yield (tonnes/ha) | 6.7 | 6.9 |
| 4 | France | Yield_T_HA | Yield (tonnes/ha) | 6.5 | 6.6 |
| 5 | India | Yield_T_HA | Yield (tonnes/ha) | 3.4 | 3.5 |
| 6 | Mexico | Yield_T_HA | Yield (tonnes/ha) | 3.5 | 3.6 |
| 7 | Nigeria | Yield_T_HA | Yield (tonnes/ha) | 2.6 | 2.7 |
| 8 | South_Africa | Yield_T_HA | Yield (tonnes/ha) | 4.2 | 4.2 |
| 9 | Ukraine | Yield_T_HA | Yield (tonnes/ha) | 6.0 | 6.1 |
| 10 | United_States | Yield_T_HA | Yield (tonnes/ha) | 10.5 | 10.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:
| Obs | Country | Cont | Reg | Prod_2023 | Prod_2024 | Yield_2023 | Yield_2024 | Prod_Growth_Rate | Yield_Growth_Rate |
|---|---|---|---|---|---|---|---|---|---|
| 1 | Ukraine | EU | EEU | 31000000 | 33000000 | 6.0 | 6.1 | 0.064516 | 0.016667 |
| 2 | India | AS | SAH | 34000000 | 36000000 | 3.4 | 3.5 | 0.058824 | 0.029412 |
| 3 | Brazil | SA | CSS | 135000000 | 142000000 | 6.4 | 6.6 | 0.051852 | 0.031250 |
| 4 | France | EU | WEU | 17500000 | 18200000 | 6.5 | 6.6 | 0.040000 | 0.015385 |
| 5 | Argentina | SA | CSS | 52000000 | 54000000 | 7.4 | 7.5 | 0.038462 | 0.013514 |
| 6 | Mexico | NA | NAM | 27500000 | 28500000 | 3.5 | 3.6 | 0.036364 | 0.028571 |
| 7 | Nigeria | AF | WA | 14500000 | 15000000 | 2.6 | 2.7 | 0.034483 | 0.038462 |
| 8 | China | AS | EAH | 290000000 | 298000000 | 6.7 | 6.9 | 0.027586 | 0.029851 |
| 9 | United_States | NA | NAM | 390000000 | 400000000 | 10.5 | 10.8 | 0.025641 | 0.028571 |
| 10 | South_Africa | AF | WA | 12500000 | 12800000 | 4.2 | 4.2 | 0.024000 | 0.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:
| Obs | Country | Cont | Reg | Seed_Type | Year | Area_HA | Production_Tonnes | Yield_T_HA | Rainfall_mm | Irrigated_Pct | Fertilizer_kg_ha | Mechanization_Idx | Export_Tonnes | Import_Tonnes | Price_USD_Ton | Export_Share | Net_Trade_Tonnes | Yield_Rank | Export_Rank |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | United_States | NA | NAM | GMO | 2024 | 37200000 | 400000000 | 10.8 | 475 | 23 | 192 | 93 | 62000000 | 1200000 | 17 | 15.5 | 60800000 | 1 | 1 |
| 2 | Argentina | SA | CSS | GMO | 2024 | 7200000 | 54000000 | 7.5 | 465 | 22 | 168 | 81 | 17000000 | 250000 | 17 | 31.5 | 16750000 | 2 | 3 |
| 3 | China | AS | EAH | HYB | 2024 | 43200000 | 298000000 | 6.9 | 545 | 42 | 178 | 79 | 9000000 | 3200000 | 20 | 3.0 | 5800000 | 3 | 4 |
| 4 | Brazil | SA | CSS | GMO | 2024 | 21500000 | 142000000 | 6.6 | 515 | 35 | 162 | 76 | 30000000 | 700000 | 16 | 21.1 | 29300000 | 4 | 2 |
| 5 | France | EU | WEU | HYB | 2024 | 2750000 | 18200000 | 6.6 | 495 | 29 | 167 | 88 | 4600000 | 130000 | 19 | 25.3 | 4470000 | 4 | 6 |
| 6 | Ukraine | EU | EEU | HYB | 2024 | 5400000 | 33000000 | 6.1 | 515 | 30 | 152 | 71 | 7500000 | 180000 | 18 | 22.7 | 7320000 | 6 | 5 |
| 7 | South_Africa | AF | WA | HYB | 2024 | 3050000 | 12800000 | 4.2 | 425 | 19 | 137 | 72 | 2600000 | 90000 | 18 | 20.3 | 2510000 | 7 | 7 |
| 8 | Mexico | NA | NAM | HYB | 2024 | 7900000 | 28500000 | 3.6 | 575 | 34 | 132 | 66 | 950000 | 5800000 | 21 | 3.3 | -4850000 | 8 | 8 |
| 9 | India | AS | SAH | HYB | 2024 | 10200000 | 36000000 | 3.5 | 615 | 46 | 122 | 56 | 900000 | 2100000 | 19 | 2.5 | -1200000 | 9 | 9 |
| 10 | Nigeria | AF | WA | OPV | 2024 | 5600000 | 15000000 | 2.7 | 730 | 11 | 62 | 26 | 220000 | 1100000 | 22 | 1.5 | -880000 | 10 | 10 |
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:
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 | Production (tonnes) | Harvested Area (ha) | Avg Yield | Exports (tonnes) | Imports (tonnes) | Avg Irrig % | Avg Fert kg ha |
|---|---|---|---|---|---|---|---|
| Africa | 27,000,000 | 8,500,000 | 3.40 | 2,700,000 | 1,300,000 | 14.0 | 97.5 |
| Asia | 324,000,000 | 53,000,000 | 5.05 | 8,700,000 | 5,700,000 | 43.0 | 147.5 |
| Europe | 48,500,000 | 7,900,000 | 6.25 | 11,500,000 | 350,000 | 28.5 | 157.5 |
| North America | 417,500,000 | 44,800,000 | 7.00 | 60,900,000 | 7,500,000 | 27.5 | 160.0 |
| South America | 187,000,000 | 28,000,000 | 6.90 | 44,000,000 | 1,200,000 | 27.5 | 162.5 |
%continent_dashboard(2024);
Output:
| Continent | Production (tonnes) | Harvested Area (ha) | Avg Yield | Exports (tonnes) | Imports (tonnes) | Avg Irrig % | Avg Fert kg ha |
|---|---|---|---|---|---|---|---|
| Africa | 27,800,000 | 8,650,000 | 3.45 | 2,820,000 | 1,190,000 | 15.0 | 99.5 |
| Asia | 334,000,000 | 53,400,000 | 5.20 | 9,900,000 | 5,300,000 | 44.0 | 150.0 |
| Europe | 51,200,000 | 8,150,000 | 6.35 | 12,100,000 | 310,000 | 29.5 | 159.5 |
| North America | 428,500,000 | 45,100,000 | 7.20 | 62,950,000 | 7,000,000 | 28.5 | 162.0 |
| South America | 196,000,000 | 28,700,000 | 7.05 | 47,000,000 | 950,000 | 28.5 | 165.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:
| Obs | Country | Continent | Region | Yield (tonnes/ha) | Yield (tonnes/ha) | Harvested Area (ha) | Exports (tonnes) | Imports (tonnes) |
|---|---|---|---|---|---|---|---|---|
| 1 | United_States | NA | NAM | 10.8 | 10.8 | 37200000 | 62000000 | 1200000 |
| 2 | Argentina | SA | CSS | 7.5 | 7.5 | 7200000 | 17000000 | 250000 |
| 3 | China | AS | EAH | 6.9 | 6.9 | 43200000 | 9000000 | 3200000 |
| 4 | Brazil | SA | CSS | 6.6 | 6.6 | 21500000 | 30000000 | 700000 |
| 5 | France | EU | WEU | 6.6 | 6.6 | 2750000 | 4600000 | 130000 |
| 6 | Ukraine | EU | EEU | 6.1 | 6.1 | 5400000 | 7500000 | 180000 |
| 7 | South_Africa | AF | WA | 4.2 | 4.2 | 3050000 | 2600000 | 90000 |
| 8 | Mexico | NA | NAM | 3.6 | 3.6 | 7900000 | 950000 | 5800000 |
%topN(metric=Export_Tonnes, yr=2024, n=8);
Output:
| Obs | Country | Continent | Region | Exports (tonnes) | Yield (tonnes/ha) | Harvested Area (ha) | Exports (tonnes) | Imports (tonnes) |
|---|---|---|---|---|---|---|---|---|
| 1 | United_States | NA | NAM | 62000000 | 10.8 | 37200000 | 62000000 | 1200000 |
| 2 | Brazil | SA | CSS | 30000000 | 6.6 | 21500000 | 30000000 | 700000 |
| 3 | Argentina | SA | CSS | 17000000 | 7.5 | 7200000 | 17000000 | 250000 |
| 4 | China | AS | EAH | 9000000 | 6.9 | 43200000 | 9000000 | 3200000 |
| 5 | Ukraine | EU | EEU | 7500000 | 6.1 | 5400000 | 7500000 | 180000 |
| 6 | France | EU | WEU | 4600000 | 6.6 | 2750000 | 4600000 | 130000 |
| 7 | South_Africa | AF | WA | 2600000 | 4.2 | 3050000 | 2600000 | 90000 |
| 8 | Mexico | NA | NAM | 950000 | 3.6 | 7900000 | 950000 | 5800000 |
%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);
The FREQ Procedure
|
| ||||||||||||||||||
No comments:
Post a Comment