libname Projects "/home/u43393119/Projects"; run; * a test;
libname Projects "/home/u43393119/Projects" xlsx
'C:\Users\user\Documents\MDM\Health outcomes formulas manuscripts\CVD Statistical tables and SAS codes\CVD output.xlsx';
%put My version of SAS is &sysvlong;
run;
Your code should be
libname Projects xlsx 'C:\Users\user\Documents\MDM\Health outcomes formulas manuscripts\CVD Statistical tables and SAS codes\CVD output.xlsx';
Your code should be
libname Projects xlsx 'C:\Users\user\Documents\MDM\Health outcomes formulas manuscripts\CVD Statistical tables and SAS codes\CVD output.xlsx';
That worked! Thanks.
Now the next part is also a problem. I want to export data that I create in libname Projects, specifically a file called Projects.source. I get error messages:
Code:
libname Projects "/home/u43393119/Projects";
proc sort data=Projects.source;
by weighted_no;
run; quit;
libname Projects xlsx
'C:\Users\user\Documents\MDM\Health outcomes formulas manuscripts
\CVD Statistical tables and SAS codes\CVD output.xlsx';
%put My version of SAS is &sysvlong;
options validvarname=v7;
data Projects.source;
set Projects.source;
run;
Log shows errors:
How do I reference my file of interest: Project.source; ?
Thanks.
You cannot have two libraries with the same name.
Are you sure your computer has access to your C drive like that? I suspect not for some reason.
To export an Excel file using libnames it would be the following:
libname myExp XLSX "/home/u43393119/Projects/sashelp_class.xlsx";
data myExp.class;
set sashelp.class;
run;
libname myExp;
Check if that works first. If it does then start playing around with different locations and data sets until you get what you want. This should work as is.
This statement has several errors:
libname Projects "/home/u43393119/Projects" xlsx 'C:\Users\user\Documents\MDM\Health outcomes formulas manuscripts\CVD Statistical tables and SAS codes\CVD output.xlsx';
First is when the engine is used for a libname it comes after the name of the library. So
libname projects xlsx
is how this should start.
Next you have two locations listed, "/home/u43393119/Projects" would not be valid as an xlsx as it is not an XLSX file. So the full libname would look like:
libname projects xlsx 'C:\Users\user\Documents\MDM\Health outcomes formulas manuscripts\CVD Statistical tables and SAS codes\CVD output.xlsx' ;
RUN; is not used with Libname statements. You would use Run to end a data step or most procedures.
BTW if you attempt to change the definition of a libname while one of it's data sets is open you may have issues. It is a good idea to use:
libname projects clear;
or what ever the name is when you are done with the library or want to change the definition.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.