Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a report using SAS 1

Status
Not open for further replies.

sreenivasreddyg

Programmer
Jan 7, 2009
1
US
I have a file with 1000 records and I need to read the last record which contains the date. By using that date I need to read all the records having the date less than the date in the last record and also need to create report. I am not sure how we can read the last record and store the date. Again, need to read the file fom the beginning. Please help. If you need any more information please let me know.
 
You can use a combination of point= and nobs= to get the last date. Nobs contains the number of observations on the dataset, while the point= allows you to specify which record of the dataset to read in. If we set this only once (at the start of the program) and rename the variable it will be automatically retained in the PDV. The example below should demonstrate this.

Code:
 data dates;
   input  name $ 1-4 @6 bday date11.;
   format bday date9.;
   cards;
John  1 Jan 1954
Mary 11 Jul 1955
Kate 12 Nov 1962
Mark  8 Jun 1959
 ;run;

data want;
   if _n_=1 then set dates(rename=(bday=last_date)) nobs=p point=p;
   set dates;
   if bday < last_date;
   run;

proc print;run;
 
Not my query, but I'll give you a star for the neat solution! That's going to be useful to me in the future.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top