BookmarkSubscribeRSS Feed
BruceBrad
Lapis Lazuli | Level 10

I have a program that imports a large number of spreadsheets into data sets. It runs fine the first time. The second time I run it, I get errors because the output data set is being used. Proc datasets also cannot delete the data sets. The code is like the following (inside a macro loop that generates different &seriesid values.

I'm using EG 8.5 (8.5.0.203) (32-bit).

filename _TSss temp;
proc http method="get"
url="&tableURL"
out=_TSss;
run;

proc import datafile=_TSss out=_TSss_&seriesid dbms=xlsx replace; range=&seriesid._data; getnames=no; run;

 

2 REPLIES 2
BruceBrad
Lapis Lazuli | Level 10

Found the problem (I think). Nothing to do with proc import. Later in the program I run this macro which I use to rename the first variable in the file. I guess I need to put a close statement in there somewhere?

%macro FirstVName(data);
%* returns the name of the first variable in a file;
%let dsid = %sysfunc(open(&data,i));
%sysfunc(varname(&dsid,1))
%mend FirstVName;
SASKiwi
PROC Star

The OPEN function will indeed create a file lock. The CLOSE function will remove it. It is always a good idea to ensure that you CLOSE OPENed files explicitly in your SAS application and not rely on just closing your SAS session which will also release these file locks. 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 526 views
  • 0 likes
  • 2 in conversation