DATA Step, Macro, Functions and more

different directory names between a Mac and a PC creates a workflow problem

Accepted Solution Solved
Reply
Contributor
Posts: 48
Accepted Solution

different directory names between a Mac and a PC creates a workflow problem

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

 

 

 

 

 


Accepted Solutions
Solution
‎04-03-2018 09:17 PM
Respected Advisor
Posts: 4,679

Re: different directory names between a Mac and a PC creates a workflow problem

@rykwong

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>";

View solution in original post


All Replies
PROC Star
Posts: 8,149

Re: different directory names between a Mac and a PC creates a workflow problem

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

 

 

Solution
‎04-03-2018 09:17 PM
Respected Advisor
Posts: 4,679

Re: different directory names between a Mac and a PC creates a workflow problem

@rykwong

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>";

Contributor
Posts: 48

Re: different directory names between a Mac and a PC creates a workflow problem

thanks everyone's kind help!

Contributor
Posts: 48

directories to where I stored my files not the same on PC and on a Mac (running windows 10)

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

 

 

 

 

 

Super User
Posts: 23,305

Re: directories to where I stored my files not the same on PC and on a Mac (running windows 10)

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. 

Valued Guide
Posts: 560

Re: directories to where I stored my files not the same on PC and on a Mac (running windows 10)

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.

Thanks,
Suryakiran
Super User
Posts: 9,913

Re: different directory names between a Mac and a PC creates a workflow problem

I merged the two identical questions.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 190 views
  • 4 likes
  • 6 in conversation