Write and run SAS programs in your web browser

Finding and saving present working directory of a SAS-Studio-program in a Linux server

Reply
Contributor
Posts: 29

Finding and saving present working directory of a SAS-Studio-program in a Linux server

 

 

 

 

 

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. 

SAS Employee
Posts: 203

Re: Finding and saving present working directory of a SAS-Studio-program in a Linux server

[ Edited ]

@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;
SAS Employee
Posts: 203

Re: Finding and saving present working directory of a SAS-Studio-program in a Linux server

@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;
Contributor
Posts: 29

Re: Finding and saving present working directory of a SAS-Studio-program in a Linux server

@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.
SAS Employee
Posts: 203

Re: Finding and saving present working directory of a SAS-Studio-program in a Linux server

@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.

Contributor
Posts: 29

Re: Finding and saving present working directory of a SAS-Studio-program in a Linux server

@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...
SAS Employee
Posts: 203

Re: Finding and saving present working directory of a SAS-Studio-program in a Linux server

@cercig,

 

You are welcome.

Ask a Question
Discussion stats
  • 6 replies
  • 203 views
  • 0 likes
  • 2 in conversation