InterviewSolution
| 1. |
Explain what is first and last in SAS? |
|
Answer» SAS Programming always uses the BY and SET statements to group data based on the order of grouping. When both BY and SET statements are used together, SAS automatically creates two temporary variables, FIRST. and LAST. 'SAS' identifies the first and last observations of a group based on the values of the FIRST. and LAST. variables. These variables are always 1 or 0, depending on the following CONDITIONS:
Essentially, SAS stores FIRST.variable and LAST.variable in a PROGRAM data vector (PDV). As a result, they become available for DATA step processing. However, SAS will not add them to the output data set since they are temporary. Example: In the following example, ID is a grouping variable containing duplicate entries. When FIRST.variable = 1 and LAST.variable = 1, it means that there is only a SINGLE value in the group like ID=4, ID=6 and ID=8 as shown below: |
|