How do I achieve to get a dataset with first.dot make in the following example.
data cars;
set sashelp.cars;
run;
proc sort data=cars out=carrs;
by make descending type;
run;
data carstype;
set carrs;
by type;
if first.type;
run;
Error in the log:
data carstype;
19621 set carrs;
19622 by type;
19623 if first.type;
19624 run;
ERROR: BY variables are not properly sorted on data set WORK.CARRS.
Make=Acura Model=NSX coupe 2dr manual S Type=Sports Origin=Asia DriveTrain=Rear MSRP=$89,765
Invoice=$79,978 EngineSize=3.2 Cylinders=6 Horsepower=290 MPG_City=17 MPG_Highway=24 Weight=3153
Wheelbase=100 Length=174 FIRST.Type=1 LAST.Type=1 _ERROR_=1 _N_=1
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 2 observations read from the data set WORK.CARRS.
You sorted by "make" first, then, within each "make" group, by "type". But you requested a sort order with "type" only in the DATA step.
The BY statements in PROC SORT and the DATA step must contain the same variables in the same order.
@Kurt_Bremser wrote:
You sorted by "make" first, then, within each "make" group, by "type". But you requested a sort order with "type" only in the DATA step.
The BY statements in PROC SORT and the DATA step must contain the same variables in the same order.
And don't forget the same DESCENDING options if used.
This is a knowledge-sharing community for SAS Certified Professionals and anyone who wants to learn more about becoming SAS Certified. Ask questions and get answers fast. Share with others who are interested in certification and who are studying for certifications.To get the most from your community experience, use these getting-started resources:
Community Do's and Don'ts
How to add SAS syntax to your post
How to get fast, helpful answers
Ready to level-up your skills? Choose your own adventure.