47 data group_last ;
48 set test;
49 by id;
50 if last.id=1;
NOTE: There were 8 observations read from the data set WORK.TEST.
NOTE: The data set WORK.GROUP_LAST has 4 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.03 seconds
53 proc print data=group_last noobs;
NOTE: Writing HTML Body file: sashtml.htm
NOTE: There were 4 observations read from the data set WORK.GROUP_LAST.
NOTE: PROCEDURE PRINT used (Total process time):
real time 1.14 seconds
cpu time 0.60 seconds
The LAST. option with a BY statement creates a numeric variable that is automatically dropped, has the value 0 for observations read in that are not the final observation of a BY group, and a value of 1 if the observation is the last observation of a BY group. This will generate the following output:
The one and only FREE resource for general SAS online training as well as study guides for the SAS Base Certification. My goal is to create the SAS Certification prep guide that I never found but always wanted. This should also be a place to come if you are new to the language but are simply looking for online SAS training.