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
Lorem ipsum
source share