I have some data in SAS that I am performing QA on. I know I can output data to different tables using IF statements etc. What I want to do is output data to a table called 'error_data' if it fails a check; however I don't want the errors table to be created if there is nothing in it.
e.g.
data good_data1 error_data1;
set sashelp.cars;
if drivetrain in("Front", "Rear", "All") then output good_data1;
else output error_data1;
run;
In this example, I want the table 'error_data' to either not be created, or deleted as there are no results in it.
The data I'm using will perform this sort of check over multiple different tables using a macro, so there will be multiple versions of 'good_data' and 'error_data'. I only want to see the 'error_data' table in the 'Output Data' list if there's something in it so that I don't have to click through every version of it to see if there's any items in them.
This processed will be wrapped in a macro, so if another step is required to remove 'error_data' from the 'Output Data' list if it contains no observations, then that would be fine.
The dataset will be created whether there are errors or not, but you can easily delete it after the fact by checking if the number of observations is 0. You can create a macro function that does this for any given dataset.