data flowersales; input CustomerID $4. +1 SaleDate MMDDYY10. +1 Variety $9. Quantity; datalines; 240W 02-07-2003 Ginger 120 240W 02-07-2003 Protea 180 356W 02-08-2003 Heliconia 60 356W 02-08-2003 Anthurium 300 188R 02-11-2003 Ginger 24 188R 02-11-2003 Anthurium 24 240W 02-12-2003 Heliconia 48 240W 02-12-2003 Protea 48 356W 02-12-2003 Ginger 240 ; proc sort data=flowersales; by descending quantity; run; /* Use of _null_ means a new SAS data set is not created by this step */ data _null_; set flowersales; if _n_=1 then call symput("selectedcustomer",CustomerID); else stop; proc print data=flowersales; where CustomerID="&selectedcustomer"; format SaleDate Worddate18.; title "Customer &selectedcustomer Had the Single Largest Order"; run; /* Without symput--I use the IN= statement and a subsetting IF--I think it's just */ /* as nice as CALL SYMPUT. However, I can't print the TITLE without MACRO commands */ /* This code assumes flowersales has already been sorted by quantity */ data b; set flowersales; if _n_=1; run; proc sort data=b; by CustomerID; proc sort data=flowersales; by CustomerID; data c; merge flowersales b (in=from_b); by CustomerID; if from_b=1; run; proc print data=c noobs label; var CustomerID SaleDate Variety Quantity; title; * I left out TITLE since I couldn't figure out how to do it; format SaleDate WordDate18.; label SaleDate='Sale Date' CustomerID='Customer ID'; run;