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.
Many thanks!
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?
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.
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.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: