Which option should be used in the DATA step to create a data set called Last_Sale that contains the last observation in Sales?

Master the SAS Base Programming Certification Exam with our comprehensive study tool. Utilize flashcards and multiple choice questions with detailed explanations. Gear up for success on your exam!

To create a dataset called Last_Sale that contains the last observation in Sales, using the END option is appropriate because it allows you to determine when the last iteration of the DATA step is occurring.

When utilizing the END option, you can set a flag that indicates when you have reached the last observation of the input dataset. This is crucial in situations where you want to capture specific records at the end of a DATA step processing. By defining a condition in conjunction with this flag, you can selectively output the last observation to your new dataset.

In this context, the LASTOBS option does not exist in SAS, and NOBS is not designed for capturing the last record but rather for counting the number of observations in a dataset. Lastly, the variable N counts the number of iterations through the DATA step but does not inherently indicate whether you are at the last observation.

Utilizing the END option enables an effective and straightforward approach to achieving the goal of creating a dataset with just the last observation from the Sales dataset.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy