how can get the first and last observations in a dataset
using Proc SQl?
Answers were Sorted based on User's Feedback
Answer / venkatesh layam
by using monotonic function u can create first and lastobs
| Is This Answer Correct ? | 6 Yes | 0 No |
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 |
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 |
what is the difference between proc report and proc format?
Have you ever used the SAS Debugger?
here is a string like chq.2312244%4452- from that i want only special characters in a column. dont use compress. bcoz i have 1.2 billion of records.i want another process to find the values instant from the data.
if you have 365 no of data set and each one having different variable from each other. how will you read by creating macros and create a single data set.
how can u extract,transform and loading?
What is the pound sign used for the DATA _NULL_?
Where do the database management systems store data and how do u import them.
What is the size of PDV?
which date functions advances a date time or date/time value by a given interval? : Sas programming
what is data integration? : Sas-di
IS SAS COMPILER OR INTERPRETER? EXPLAIN?
3 Answers Aon Hewitt, HSBC, SCL, TCS,
what can you learn from the sas log when debugging? : Sas programming