Enhance error handling for empty datasets

The program runs into an error when a dataset without data is referenced in a project.