08-05-2016 04:55 PM
Is there a way to find out the data-set-ids of all the data set that are currently open? It happens when I don't know the data-set-ids but I want to close all the data sets.
08-05-2016 05:27 PM
Are you using this in macro code or a data step? The data step version closes all data sets at the end of the data step execution.
You are responsible for maintaining the dataset id variables. You should assign a unique variable to hold each dataset identifier. If you aren't doing that then you need to pay attention to the recommendation from the documentation: Close all SAS data sets as soon as they are no longer needed by the application.
Generally the worse thing that will happen in you attempt to close a set that isn't open is the return code will be negative. If you don't the variables that are holding the IDs then you really need to rewrite some code.
What are you doing that you need to have multiple datasets open using the open/close functions in the first place?
08-05-2016 05:41 PM
Thanks so much for the reply. I am trying to use it in a macro. But I think your suggestion is correct. I should manage the dataset correctly when I use it instead of trying find the dataset id and closing the dataset.
08-05-2016 05:48 PM
Especially if you are doing this in some sort of loop. It gets easy to open multiple sets using the same id variable. At which point you can only get to that one dataset for closure.