Hi,
I have stored my sas programs and data in my dropbox subfolders
so when I run SAS (using parallels), these files can be read using for example:
libname home '\\.psf\Home\Dropbox (Partners HealthCare)\BWH Cardiac MR\Grants.......
I also run sas on windows 10 PC, but the same file will have this directory
libname home '\\C:\User\rk64\Dropbox (Partners HealthCare)\BWH Cardiac MR\Grants......
I have to change these directories if I want to use SAS sometimes on windows and sometimes on Mac. Do you know of a way to not have to changes these directories each time?
thanks and much appreciated
Or to extend what @art297 writes: Just define the environment dependent part via a macro or even simply via just creating a macro variabl like "root_path" in a place like the autoexec. That's quite a common approach.
Then in your code write all paths like "&root_path/<your path>";
Hi,
I have stored my sas programs and data in my dropbox subfolders
so when I run SAS (using parallels), these files can be read using for example:
libname home '\\.psf\Home\Dropbox (Partners HealthCare)\BWH Cardiac MR\Grants.......
I also run sas on windows 10 PC, but the same file will have this directory
libname home '\\C:\User\rk64\Dropbox (Partners HealthCare)\BWH Cardiac MR\Grants......
I have to change these directories if I want to use SAS sometimes on windows and sometimes on Mac. Do you know of a way to not have to changes these directories each time?
thanks and much appreciated
I don't know of an easy way, but what I'll do for situations like this is create a macro variable at the top of your program that has the path to the files. Then use the macro variable in your program (make sure to use double quotes. Comment out the appropriate path based on where you are. Not ideal but works for me. Another option is to create this path in each system using your autoexec but this seems more understandable to me.
*work;
%let path = \\.psf\Dropbox (Partners HealthCare)\....;
*home;
%let path = \\c:\user\dropbox ... ;
libname myfiles "&path.\data sets";
PS You should consider using Box instead of DropBox, because Box is HIPPAA compliant, but DropBox is not unless you have a separate set up. Its possible this has changed since the last time I checked as well.
If your using SAS EG then there is a automatic macro variable "_CLIENTMACHINE". Define the path based on this value and then it will be easy for you and can avoid editing the code.
I personally never tried, just my idea. Give a try and see and let rest of us know your findings.
One way would be to create and store a macro and, for each machine, have it run whenever you start SAS. e.g.:
%macro sethome; %if &sysscp=WIN %then %do; libname home '\\C:\User\rk64\Dropbox (Partners HealthCare)\BWH Cardiac MR\Grants'; %end; %else %do; libname home '\\.psf\Home\Dropbox (Partners HealthCare)\BWH Cardiac MR\Grants'; %end; %mend sethome; %sethome
Art, CEO, AnalystFinder.com
thanks everyone's kind help!
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!
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.