Use &syshostname instead of %syshostname
% is used to identify a macro, but & is used to show the value of a macro variable.
Needless to say, it's important to know the difference between a macro and a macro variable, but most people just call them macros.
Whenever I can influence things, then I make sure that directory structures are identical between environments. I don't think coding environment smart within individual scripts is a good approach.
What's sometimes different is the "Root path". What I'm normally doing in such a case is to implement SAS macro variables in the Autoexec and so I keep all environment specific information in a single location for maintenance.
A libname statement would then look like:
libname myds "&data\subfolder1\subfolder2";
Where the "subfolders" are the part of the directory structure under my control and identical in all environments.
An alternative approach for libraries used in multiple programs would be, to define these libraries in SAS Metadata. This is again about keeping environment specific things in a central location and not spread out over many programs which becomes a maintenance nightmare in case something ever changes - and for example the host name will change when you upgrade to a current SAS version in a hopefully not too far future for you.
If you don't have the necessary level of access to modify the Autoexec or to change SAS Metadata then a 3rd option would be to create a %init macro with all these environment specific definitions. Store the macro code in a folder which is part of the SAS Autocall facility and then just call the macro always at the beginning of your programs.
Hi @Patrick
Hmmm, somehow I think you posted in the wrong topic.
This is a 7 years old discussion 🙂
Daniel Santos @ www.cgd.pt
LOL! How did that happen? No idea how I've even got to such an old thread.
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 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: