BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rykwong
Quartz | Level 8

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

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

@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

7 REPLIES 7
rykwong
Quartz | Level 8

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

 

 

 

 

 

Reeza
Super User

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. 

SuryaKiran
Meteorite | Level 14

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
art297
Opal | Level 21

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

 

 

Patrick
Opal | Level 21

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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