Check nobs for the dataset beforehand (save to a macro variable), and wrap the dataset conditionally in a macro. Use that macro in place of the dataset name in the set statement.
Ready to join fellow brilliant minds for the SAS Hackathon?
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.