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 can get the first and last observations in a dataset
using Proc SQl?

Answers were Sorted based on User's Feedback



how can get the first and last observations in a dataset using Proc SQl?..

Answer / venkatesh layam

by using monotonic function u can create first and lastobs

Is This Answer Correct ?    6 Yes 0 No

how can get the first and last observations in a dataset using Proc SQl?..

Answer / venkatesh layam

crate one data in sql with adding of new var (a = 1) and
sort(order by) descending order by another variable and
take distinct of a (newvar-which is already created) --then
u wil get last observation.

next do ascending and get first obs ,then union these two
data sets .u will get first and last obs.

Is This Answer Correct ?    0 Yes 0 No

how can get the first and last observations in a dataset using Proc SQl?..

Answer / rohitbedi

Create a new data set as below:

data demo;
input year month cpi;
datalines;
1990 6 129.9
1990 7 130.4
1990 8 131.6
1990 9 132.7
1991 4 135.2
1991 5 135.6
1991 6 136.0
1991 7 136.2
;
run;

Sort the data if needed.

Create a new id field:

data demo2;
set demo;
id = _n_;
run;

Display the first and last record for every date and finally remove the id column.

proc sql;
create table final as select * from demo2 where id in (select min(id) from demo2 group by year) or id in (select max(id) from demo2 group by year);
alter table final drop column id;
quit;

Is This Answer Correct ?    0 Yes 0 No

how can get the first and last observations in a dataset using Proc SQl?..

Answer / naveen

proc sql;
select first(orderprise)
from xxx;
quit;

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More SAS Interview Questions

How to write duplicate records into a separate dataset using sort?

4 Answers   HSBC,


how can u import .csv file in to SAS?tell Syntax?

7 Answers   CitiGroup, Franklin Templeton,


How do you put a giraffe into the refrigerator?

3 Answers   Oracle,


Explain proc sort?

0 Answers  


How do you define proc in sas? : sas-grid-administration

0 Answers  


Hi, I have one dataset, could you please ans for this. id amount paid_amount 1 700 400 2 900 250 3 300 300 a 400 250 b 500 320 c 800 650 x 200 190 y 900 250 z 300 180 i want create new dataset having id and paid_amount who are paid high amount comparing amount. ex: 1d paid_amount 3 300 c 650 x 190

3 Answers  


What are the applications primarily used by business analyst? : Sas-bi

0 Answers  


what is option year cuttoff in sas

2 Answers   L&T,


what are some differences between proc summary and proc means? : Sas programming

0 Answers  


Which date functions advances a date time or date/time value by agiven interval?

3 Answers  


Difference Between Scan and Substr

2 Answers  


What happens in the following code, if u type 8 instead of *? proc sql noprint; create table abc as select 8 from lib.abc; quit;

3 Answers  


Categories