In SQL, there is no concept of an observation number in tables, as there is when using Data step (i.e. _N_ or a SUM statement count+1) with a SAS dataset. In a dataset, we can select data using an observation number by using firstobs= obs= or _N_.
Proc SQL with the NUMBER option prints the row number on a report but does not store the value in the dataset.
In SAS 9 and later, the MONOTONIC() function will return the equivalent observation number that can be stored in the dataset…
select monotonic() as rowno, * |
You can also the monotonic() to subset the dataset in the where clause to limit the number of records read / outputted to the final dataset…
select monotonic() as rowno, * |
where 10 le monotonic() le 20; |
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.