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

describe about metadata object? : Sas-di

1078


what other sas products have you used and consider yourself proficient in using? : Sas programming

1116


what is the difference between infile and input? : Sas-administrator

1148


what are the scrubbing procedures in sas? : Sas programming

1287


What are the new features included in the new version of SAS Programming Language?

1214


List out some key concept of SAS

1136


What are types of transport files?

8010


Mention some common errors that are usually committed in sas programming.

1056


What is the basic structure of a sas program?

1126


What does proc print, and proc contents are used for?

1139


How sas treats the dsd delimiters?

1219


What is run-group processing?

1173


what is the primary data source for the wrs? : Sas-bi

1243


what are several options for creating reports in web report studio? : Sas-bi

1159


What is the difference between INPUT and INFILE ?

1330