Hi,
I've been using the libname Excel method of writing to a named range in an Excel sheet for a few monbths, since a colleague at work introduced me to the technique and have found it very useful. I am having issues with it at the moment though in as much as for a particular sheet, when I run the code, the log tells me the code has run successfully but the Excel sheet has not been updated.
I have run the code a couple of times today and it has worked (the Excel file shows as having been modified at 11:08 today) but when I have run it again since, it is not updating. I have checked that it was trying to write to the correct location (which I knew it was) by running the code with the Excel file open and the code errors, and I have checked that the named ranges still exist within the file (which they do) so I just don't know what else it could be.
The output datasets have three variables in, a date, a character variable and a number (in percent format) - example attached.
The code I am using is below: -
%let xlpath= ##\Covid\Arrears_Summary_Covid_&covid..xlsx;
libname xl Excel "&xlpath.";
proc datasets lib=xl nolist;
delete &next_value._Rate;
quit;
data xl.&next_value._Rate;
set &next_value._totals_2_covid_&covid.;
run;
libname xl clear;
And the log shows this: -
NOTE: Libref XL was successfully assigned as follows:
Engine: EXCEL
Physical Name: ##\Covid\Arrears_Summary_Covid_1.xlsx
NOTE: Deleting XL.Improve_Rate (memtype=DATA).
NOTE: PROCEDURE DATASETS used (Total process time):
real time 0.00 seconds
11 The SAS System 10:39 Wednesday, May 6, 2020
cpu time 0.00 seconds
NOTE: SAS variable labels, formats, and lengths are not written to DBMS tables.
NOTE: There were 52 observations read from the data set WORK.IMPROVE_TOTALS_2_COVID_1.
NOTE: The data set XL.Improve_Rate has 52 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
NOTE: Libref XL has been deassigned.
Does anyone have any thoughts as to what could be causing this, only it's a huge frustration for me at the moment. Nothing of any consequence has been changed in the code between runnings so I'm really at a loss as to why it worked previously but not now.
Thanks,
Rob
What happens if you just run the delete portion?
Please post the log as well.
@robulon wrote:
by deleting the range using proc datasets, the initial size of it shouldn't come into play.
You do not delete the range, it deletes the data in the range but the named range still exists. You can check this when you run your code in sections.
Where are you indicating the named ranges?
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.