## Monday, November 3, 2008

### How to determine the last observation in a data set

Determine the last observation in a data set

Use the END= option on a SET statement to determine the last observation of the data set.

/* Create sample data */
data company;
input division :\$12. employees;
datalines;
sales 150
support 200
research 250
accounting 50
shipping 35
; run;

/* Calculate the total number of employees in each group. */
/* On the last observation of the data set, write out the */
/* resulting total. */

data _null_;
set company end=last;
file print;
/* Sum statement syntax has an implied RETAIN */
total + employees;
/* For every iteration of the step, write out the values for */
/* DIVISION and EMPLOYEES. */
put @1 division @15 employees;
/* On the last iteration of the step only, write out 4 dashes */
/* starting at column 15, move the internal pointer to the next */
/* line and at column 15 write out the value of TOTAL. */

if last then put @15 '----' / @15 total;
run;

RESULT:
sales 150
support 200
research 250
accounting 50
shipping 35
----
source: http://support.sas.com/kb/24/746.html

#### 1 comments:

Anonymous said...

welcome to the wow power leveling cheap Wow gold service site, buy cheap wow gold,wow gold,world of warcraft power leveling buy wow gold

ShareThis