data bikemodels; length Model $12 Class $8 Frame $15; input Model $ Class $ Price Frame $; cards; BlackBora Track 796 Aluminum DeltaBreeze Road 399 CroMoly JetStream Track 1130 CroMoly Mistral Road 1995 CarbonComp Nor'easter Mountain 899 Aluminum SantaAna Mountain 459 Aluminum Scirocco Mountain 2256 Titanium TradeWind Road 759 Aluminum ; run; proc print data=bikemodels; run; * subsetting with WHERE; proc print data = bikemodels noobs; where Type = 'Mountain'; format Price dollar6.; title 'Current Models of Mountain Bicycles'; run; title; * using a MACRO; %LET bikeclass = Mountain; proc print data = bikemodels noobs; where Class = "&bikeclass"; format Price dollar6.; title "Current Models of &bikeclass Bicycles"; run; *without the macro; proc print data=bikemodels noobs; title 'Current Models'; var Model Class Frame Price; format Price dollar6.; run; proc sort data=bikemodels; by Price; run; proc print data=bikemodels noobs; title 'Current Models'; var Model Class Frame Price; format Price dollar6.; run; * with the macro; %macro printit; proc print data=bikemodels noobs; title 'Current Models'; var Model Class Frame Price; format Price dollar6.; run; %mend printit; %printit proc sort data=bikemodels; by Price; run; %printit * without macro; proc sort data=bikemodels; by descending Price; run; proc print data=bikemodels noobs; title 'Current bikemodels'; title2 "Sorted by Descending Price"; format Price dollar6.; run; proc sort data=bikemodels; by Class; run; proc print data=bikemodels noobs; title 'Current bikemodels'; title2 "Sorted by Class"; format Price dollar6.; run; * with the macro to run the PROC PRINTs and PROC SORTs; %macro sortandprint(sortseq=, sortvar=); proc sort data=bikemodels; by &sortseq &sortvar; run; proc print data=bikemodels noobs; title 'Current bikemodels'; title2 "Sorted by &sortseq &sortvar"; format Price dollar6.; run; %mend sortandprint; %sortandprint(sortseq=Descending, sortvar=Price) %sortandprint(sortseq=, sortvar=Class) options mprint; data orders; length Model $11; input CustomerID $ OrderDate:date7. Model $ Quantity; cards; 287 15OCT03 Delta Breeze 15 287 15OCT03 Santa Ana 15 274 16OCT03 Jet Stream 1 174 17OCT03 Santa Ana 20 174 17OCT03 Nor'easter 5 174 17OCT03 Scirocco 1 347 18OCT03 Mistral 1 287 21OCT03 Delta Breeze 30 287 21OCT03 Santa Ana 25 ; run; proc print data=orders; run; %macro reports; %if &sysday = Monday %then %do; proc print data=orders noobs; format OrderDate date7.; title "&sysday Report: Current Orders"; %end; %else %if &sysday = Friday %then %do; proc tabulate data=orders; class CustomerID; var Quantity; table CustomerID ALL, Quantity; title "&sysday Report: Summary of Orders"; %end; %mend reports; run; %reports run;