12-06-2016 12:32 AM
data orders; input CustomerID$1-3 OrderDate DATE7. Model $13-24 Quantity ; datalines; 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 NOOBS; where customerID ='&customerclass'; format quantity ; title 'current models of &customerclass bicycles'; run; %MACRO PRINTIT; proc print data =orders NOOBS; title 'current models'; var CustomerID OrderDate Model Quantity; format quantity ; run; %MEND printit; %printit proc sort data=models; by quantity; %printit
1. I want to classify the same customers' ID into a group and then plus their quantity together what command I can use?
2. How to controll the quantity in increasing order or decreasing order ?
12-06-2016 03:57 AM
proc sort data=orders; by CustomerID; run; proc summary data=orders ; by CustomerId; var quantity; output out=want mean=mean_qty; run; proc sort data =want ; by mean_qty; run;
12-06-2016 04:38 AM
There are a few items to clean up first:
Once those issues are cleared up, you can look at how PROC SORT can change the order of the observations. At that point, you can also consider whether you want to group all customers, or whether you want to process only a single CustomerID.
12-08-2016 06:43 AM
For point 1, change all single quotes to double quotes.
For point 2, you have to decide on the result you want. Do you actually want to print the data set twice (once before sorting, and once after sorting)? If you only want to print it once, when should it print (again, before vs. after sorting)?