Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


how do i get last 10obs from a dataset when we don't know
about the number of obsevations in that dataset?

Answers were Sorted based on User's Feedback



how do i get last 10obs from a dataset when we don't know about the number of obsevations in ..

Answer / raghu

proc sql;
select count(*) into : cnt from ds;
quit;

data ds1;
set ds(firstobs=%eval(&cnt-9) obs=&cnt);
run;

Is This Answer Correct ?    21 Yes 0 No

how do i get last 10obs from a dataset when we don't know about the number of obsevations in ..

Answer / shiva

data a;
do i=1 to 100;
output;
end;
run;

data data1;
set a nobs=tot;
if _n_ gt( tot-10) then output data1;
run;

Is This Answer Correct ?    20 Yes 4 No

how do i get last 10obs from a dataset when we don't know about the number of obsevations in ..

Answer / harshal r

data air;
set sashelp.air nobs=tot;
if _n_ gt( tot-10) then output;
run;

Is This Answer Correct ?    8 Yes 1 No

how do i get last 10obs from a dataset when we don't know about the number of obsevations in ..

Answer / naveen

Thank you Shiva

Is This Answer Correct ?    6 Yes 6 No

how do i get last 10obs from a dataset when we don't know about the number of obsevations in ..

Answer / pratik

Suppose we have dataset like sasuser.admit.

we dontknow how many obs are there in this dataset.

then we can use
Proc contents data=sasuser.admit n;
run;
it will come the total no of obs in this dataset.

after doing this you will get 21 obs are there.

data dsn1;
set sasuser.admit(firstobs=12 obs=21);
run;
proc print data=dsn1;
run;
then you will get last 10 obs.

Is This Answer Correct ?    2 Yes 2 No

how do i get last 10obs from a dataset when we don't know about the number of obsevations in ..

Answer / sumit

data new;
set old;
n = _N_;
run;

Proc sort data = new;
by descending n;
run;
Option OBS= 10;
Proc sort data = new (drop = n);
by descending n;
run;

Is This Answer Correct ?    2 Yes 3 No

how do i get last 10obs from a dataset when we don't know about the number of obsevations in ..

Answer / its me

Shiva, ur answer is also correct . and here goes another
one dear..

data W;
set X;
if _n_ > 95 then output;
run;


As the total no. of obs are 100, the last five observations
will be be in ur output dataset..
Cheers!!!

Is This Answer Correct ?    1 Yes 14 No

Post New Answer

More SAS Interview Questions

i want for interview question & answer plz it need immediate send t my mail raviprakashmot@gmal.cm

0 Answers   SAS,


How sas treats the dsd delimiters?

0 Answers  


What is the maximum length of the macro variable? : sas-macro

0 Answers  


what are all the reports you generated in your recent project?

0 Answers   Accenture, Quintiles,


What are the automatic variables for macro? : sas-macro

0 Answers  


How do you test for missing values?

0 Answers   Quintiles,


Name types of category in which SAS Informats are placed?

0 Answers  


what has been your most common programming mistake? : Sas programming

0 Answers  


what is the diff. b/w proc means and proc summary?

12 Answers   CitiGroup,


how to shift the rows to cols? eg: i have like field1 field2 field3 10 20 20 this should be displayed as field1 10 field2 20 field3 30 (without the obs col) how do this?can i use transpose or tell me suitable way to do this?

3 Answers   CMC,


where will go the observations that were deleted by delete statement?

2 Answers  


which stats created by proc means that are not created by proc summary or vice versa?

2 Answers   GSK,


Categories