Working with Time Series Data |
Sorting by Time |
Many SAS/ETS procedures assume the data are in chronological order. If the data are not in time order, you can use the SORT procedure to sort the data set. For example,
proc sort data=a; by date; run;
There are many ways of coding the time ID variable or variables, and some ways do not sort correctly. If you use SAS date or datetime ID values as suggested in the preceding section, you do not need to be concerned with this issue. But if you encode date values in nonstandard ways, you need to consider whether your ID variables will sort.
SAS date and datetime values always sort correctly, as do combinations of numeric variables such as YEAR, MONTH, and DAY used together. Julian dates also sort correctly. (Julian dates are numbers of the form yyddd, where yy is the year and ddd is the day of the year. For example, 17 October 1991 has the Julian date value 91290.)
Calendar dates such as numeric values coded as mmddyy or ddmmyy do not sort correctly. Character variables that contain display values of dates, such as dates in the notation produced by SAS date formats, generally do not sort correctly.
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.