Change current folder

I want to specify the current folder. I can find the current folder:

libname _dummy_ "."; %let folder = %NRBQUOTE(%SYSFUNC(PATHNAME(_DUMMY_))); %put &folder; 

and change it manually by double-clicking the status bar of the current folder, but I would prefer to encode it. Is it possible?

+8
sas
source share
2 answers

Like this:

 x 'cd <full path>'; 

eg

 x 'cd C:\Users\foo'; 

SAS recognizes that the change catalog command was issued by the OS and changes the current working directory.

+9
source share

Keep in mind that the execution time of the X operator is similar to how other global operators do (heading, footnote, parameters, etc.). If it is placed on a DATA step, an X statement will be issued before the data step is completed.

For example, suppose your current working directory is c:\temp . The following writes HelloWorld.txt to c:\temp2 , not c:\temp . At compile time, SAS runs the X statement and then executes the data step. Note that in SAS, the period ( . ) Is a link to the current working directory.

 data _null_; file '.\HelloWorld.txt'; put 'Hello, world!'; x 'cd C:\temp2'; run; 

To change directories after completing the data step, you would like to use the CALL SYSTEM . CALL statements are executed conditionally, invoking them after the data step.

 data _null_; file '.\HelloWorld.txt'; put 'Hello, world!'; command = 'cd "C:\temp2"'; call system(command); run; 

For more information on these details for Windows systems, see Running Windows or MS-DOS Commands from SAS

0
source share

All Articles