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?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What versions of SAS have you used (on which platforms)?

1456


what versions of sas have you used (on which platforms)? : Sas programming

1003


which date function advances a date, time or datetime value by a given interval? : Sas programming

994


Explain data_null_?

1003


how many display types available in sas bi dashboard? : Sas-bi

1032


How can you create a macro variable with in data step? : sas-macro

984


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

2128


what is null hypothesis? why do you consider that?

2847


How will you react when, while consulting a SAS documentation manual to get an answer to a problem, someone says hey, I thought you were supposed to know all that stuff already, and not have to look it up in a book?

2401


what are 5 ways to perform a table lookup in sas? : Sas-administrator

1179


what cause the "error: connect:" and "error in the libname statement" when there weren't any such problems?

2125


Explain input and put function?

1082


How do dates work in SAS data?

1116


What is SAS? What are the functions does it performs?

1138


explain the proc in sas? : Sas-administrator

1034