Friday, June 5, 2009

How To obtain first n observaton in the dataset

we have the following dataset(vikas.health_data)


The SAS System 2

Obs subj dob visitdate lastdate age agetoday

1 001 21OCT1950 12MAY2003 01DEC2004 55 43
2 002 12SEP1955 10FEB1984 24MAR2002 50 38
3 003 21MAR1965 12SEP1987 25JAN2000 40 28
4 004 02AUG1975 13OCT1975 29DEC1999 30 18
5 005 04FEB1985 21AUG1980 20OCT1998 20 8
6 006 11OCT1980 10JAN1955 23MAR2001 25 13
7 007 15OCT1981 09MAR1950 12MAY2002 24 12
8 008 24OCT1956 06APR1970 01JUL2003 49 37
9 009 12JUN1954 17SEP1988 12AUG2003 51 39
10 010 16JUL1952 21FEB1955 13SEP2000 53 41
11 011 21FEB1980 16APR1960 28OCT2001 25 13
12 012 18MAY1981 19MAY1963 20DEC2000 24 12
13 013 24JAN1983 21JUN1964 21SEP2000 22 10
14 014 25SEP1984 25OCT1968 23OCT2003 21 9
15 015 05NOV1976 27NOV1970 24NOV2006 29 17


Let us suppose that you have a dataset having thousands of observation and you want to display only first few observation to save processing resources and time…
suppose the given data set is above ….it is having 15 observations.
now if we want only first 10 obs then we can use the foeelowing code in for the proc print –


proc print data=vikas.health_data (obs=10) ;
run;

the option ‘obs’ tells sas to read till 10 th observation.
Similarly , the code

proc print data=vikas.health_data ( firstobs=5 obs=10) ;
run;

outputs the observations from 5 to 10th in the dataset health_data stored in the library named vikas.

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