BookmarkSubscribeRSS Feed
cercig
Obsidian | Level 7

 

 

 

 

 

I need to manage the historical versions of the model manually, and my plan was creating a copy of the model under another map and SAS would recognize the new map automatically without changing the macro variables.

 

I am trying to make a macro variable in SAS Studio which saves the "present working directory" as a macro variable.

The SAS-program is run in a "CPF" process flow file in SAS Studio, and the whole SAS-file and processes are saved and run in a Linux server.

In SAS-Studio, the location of CPF-process flow file seems like in the directory /sasdata/prodpgm/Test..., and when I run a Linux command like 

data _null_;
rc = system( 'pwd' );
%put rc;
run;

then I expect that the result will give /sasdata/prodpgm/Test..., but I get another directory instead like /sasinstall/sasconfig/Lev1/SASApp instead, I guess the the process flow file with CPF-suffix is run from this directory.

 

So the question is how I can find and save the working directory of my cpf-file and save as a macro-variable, or even maybe for my other sas-files too, I may need the solution for both SAS-files and CPF-files.

 

I asked the same question on another forum, and some said that SAS-Studio can't find your working directory automatically, I need to assign the path myself. 

 

The software specifications: SAS Studio release 3.6 (enterprise edition). SAS release: 9.04.01M4P11092016. SAS platform: Linux LIN X64 3.10.0-514.26.1.el7.x86_64. 

6 REPLIES 6
alexal
SAS Employee

@cercig,

 

Beginning with SAS 9.4 TS1M4, you can change the current working directory via SAS code by using the new DLGCDIR function. Here is an example:

 

data _null_;
  rc=DLGCDIR(“/sasdata/prodpgm/”);
  put rc=;
run;
alexal
SAS Employee

@cercig,

 

Also, in SAS 9.4 TS1M4 you can use the following code to write the value of the current working directory to the log: 
  

data _null_; 
  rc=DLGCDIR(); 
  put rc=; 
run;
cercig
Obsidian | Level 7
@alexal Thanks. But this data-step with DLGCDIR() gives also the systempath "/sasinstall/sasconfig/..." instead of "/sasdata/prodprgm/..." . I want the SAS-Studio to find the working path "/sasdata/prodpgm/..." automatically without referring manually.
alexal
SAS Employee

@cercig,

 

That's right because you are starting the workspace server from the configuration directory. 

 

without referring manually.

 

You should be able to use these statements with DLGCDIR in an AUTOEXEC file in SAS Studio so that they get submitted to SAS each time you invoke SAS Studio.

cercig
Obsidian | Level 7
@alexal
I needed automization because I need to handle the model versions manually right now. So if I need to define the working path manually with each version of the model (each version will be under its own map), then there is no difference between using DLGCDIR() or typing the path manually in each time.
Thanks anyway...

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 6 replies
  • 4533 views
  • 0 likes
  • 2 in conversation