Friday, June 5, 2009

How to obtain laast n observations from the dataset

how to obtain last ‘n’ observation from a dataset—


The step to obtain last observation can be done in data step by using the following code since there are no options for obtaining last ‘n’ observations (like obs which indicates last obs to be read starting from first and firstobs which indicates starting obs , there is no lastobs option which takes us to the last starting from any observation in between)

data data1;
set vikas.health_data nobs=tot;


if _n_ gt( tot-5) then output data1;
run;
outputs—

Obs subj dob visitdate lastdate age agetoday

1 011 21FEB1980 16APR1960 28OCT2001 25 13
2 012 18MAY1981 19MAY1963 20DEC2000 24 12
3 013 24JAN1983 21JUN1964 21SEP2000 22 10
4 014 25SEP1984 25OCT1968 23OCT2003 21 9
5 015 05NOV1976 27NOV1970 24NOV2006 29 17

Send link to --

TopBlogDir.blogspot.com button Education Blog Directory Academic,  Learning & Educational Blogs - Blog Catalog Blog Directory SEO Court Directory myblog Visit blogadda.com to discover Indian blogs Add to Technorati Favorites Subscribe with Bloglines DigNow.net

Join My Community at MyBloglog!

Free Web Directory - Add Your Link
The Little Web Directory
Monster Directory A List Sites