Sairam,
The following utility macro might solve your problem:
%MACRO obs(lib=,mem=);                    
 %LET ds    = %SYSFUNC(OPEN(&lib..&mem)); 
 %LET noobs = %SYSFUNC(ATTRN(&ds,NOBS));  
 %LET ds    = %SYSFUNC(CLOSE(&ds));       
 &noobs;                                  
%MEND  obs;                               
If we generate the following dataset - a1
data a1;
  do val = 1 to 100;
   output;
  end;
run;
Use the macro statement - %LET to assign a macro variable (obs_in_dset in this example) the output of the %obs macro. In the macro call name the sas library in which your dataset resides (lib=work) and the sas dataset name (mem=a1)
e.g.
%let obs_in_dset = %obs(lib=work,mem=a1);
Now when you want to read the last obs in the a1 dataset use
data lastina1;
 set a1(firstobs=&obs_in_dset);
run;
I hope you find this useful.
Regards,
BPD