Change current folder
I'd like to specify the current folder. I can find the current folder:
lib开发者_如何学运维name _dummy_ ".";
%let folder = %NRBQUOTE(%SYSFUNC(PATHNAME(_DUMMY_)));
%put &folder;
and change it manually by double clicking the current folder status bar, but I'd prefer to code it. Is this possible?
Like this:
x 'cd <full path>';
for example
x 'cd C:\Users\foo';
SAS recognizes that a change directory command was issued to the OS and changes it's current working directory.
Be aware that the timing of an X
statement is like that of other global statements (title, footnote, options, etc). If it is placed within a DATA step, the X
statement will be issued prior to the data step execution.
For example, supposing your current working directory is c:\temp
. The following writes HelloWorld.txt
to c:\temp2
rather than c:\temp
. At compile time, SAS runs the X
statement and then performs the data step. Note that in SAS, a period (.
) is the reference to the current working directory.
data _null_;
file '.\HelloWorld.txt';
put 'Hello, world!';
x 'cd C:\temp2';
run;
To change directories after the data step has executed, you would want to use CALL SYSTEM
. CALL statements execute conditionally by being called after a data step.
data _null_;
file '.\HelloWorld.txt';
put 'Hello, world!';
command = 'cd "C:\temp2"';
call system(command);
run;
More information about these kinds of details for Windows systems can be found in the Running Windows or MS-DOS Commands from within SAS
精彩评论