BookmarkSubscribeRSS Feed
jc3992
Pyrite | Level 9

hello everyone,

 

my code is as below:

 %let dirdata='/folders/myfolders';
libname perm '&dirdata';
run;

And the LOG shows:

 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         %let dirdata='/folders/myfolders';
 74         libname perm '&dirdata';
 NOTE: Library PERM does not exist.
 75         run;
 76         
 77         
 78         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 91         

I wonder if there is any method to create a permanent libname in SAS Studio?

Is there anyone kindly tell me what did I do wrong?

 

Thanks!

7 REPLIES 7
Reeza
Super User

Macro variables only resolve in double quotes, not single quotes. 

 


@jc3992 wrote:

hello everyone,

 

my code is as below:

 %let dirdata='/folders/myfolders';
libname perm '&dirdata';
run;

And the LOG shows:

 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         %let dirdata='/folders/myfolders';
 74         libname perm '&dirdata';
 NOTE: Library PERM does not exist.
 75         run;
 76         
 77         
 78         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 91         

I wonder if there is any method to create a permanent libname in SAS Studio?

Is there anyone kindly tell me what did I do wrong?

 

Thanks!


 

jc3992
Pyrite | Level 9
 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         %let dirdata= "/folders/myfolders";
 74         libname perm "dirdata";
 NOTE: Library PERM does not exist.
 75         run;
 76         
 77         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 90         

still did not work though

Reeza
Super User
 73         %let dirdata= "/folders/myfolders/";
 74         libname perm "dirdata";

Does that work?

 

Did you update SAS UE? I thought we'd worked through this a few weeks ago.  

jc3992
Pyrite | Level 9

No that did not work.

 

Last weekend I was using SAS 9.4 on the computer lab

now the same problem happened with SAS Studio

Kurt_Bremser
Super User

@jc3992 wrote:
 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         %let dirdata= "/folders/myfolders";
 74         libname perm "dirdata";
 NOTE: Library PERM does not exist.
 75         run;
 76         
 77         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 90         

still did not work though


No miracle. You deleted the necessary ampersand. Try

%let dirdata=/folders/myfolders;
libname perm "&dirdata";
jc3992
Pyrite | Level 9

I succeeded by the code as below:

%let dirdata=/folders/myfolders;
libname perm "&dirdata";
run;
 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         
 74         %let dirdata=/folders/myfolders;
 75         libname perm "&dirdata";
 NOTE: Libref PERM was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /folders/myfolders
 76         run;
 77         
 78         
 79         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 92         
Reeza
Super User

Right...you had double quotes in each location, it goes in one or the other. 

 

But like I mentioned before, you really don't need the macro variable step at all. And macros are just confusing in the beginning. 

If you do want to work with macros, first make sure you have working code and then start adding the macro components.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

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
  • 7 replies
  • 2934 views
  • 1 like
  • 3 in conversation