Take the 2-minute tour ×

I know that Sas starts with the observation at the top of a dataset when processing and proceeds to the next until it reaches the bottom observation, but is there an easy way to make sas process the bottom observation first and then work its way to the top?

share|improve this question

2 Answers 2

You certainly can change your data to be in reverse order, then process top down. Add a variable to the data set which acts as an index..then sort the data set descending by that variable.

data work.myData ;
 set work.myData ;
 indx = _n_ ;
run ;

proc sort data=work.myData ;
 by descending indx ;
run ;
share|improve this answer
+1 for a version which works with views as well as data sets –  Simon Nickerson May 28 '09 at 15:00

You can use nobs and point to process it backwards without having to do any intermediate steps. Here's an example:

data backwards;
  do k= nobs to 1 by -1;
   set sashelp.class nobs = nobs point=k;
proc print data=sashelp.class;run;
proc print data=backwards;run;

See page 2 of this pdf for all the juicy details.

share|improve this answer
Nice tip and link –  CarolinaJay65 May 28 '09 at 19:04

Your Answer

