BookmarkSubscribeRSS Feed
scope4
Calcite | Level 5

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!

3 REPLIES 3
ballardw
Super User

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?

scope4
Calcite | Level 5

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.

ballardw
Super User

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1099 views
  • 0 likes
  • 2 in conversation