Use DOS Command in SAS

All DOS commands can be used in the following sytax to run in SAS, assuming XCMD is enabled in SAS.

Most common DOS command are copy, mkdir. It can be used to create new directories, files etc. The comand needs to be put in single quoatation ‘ ‘.  If there is space in the folder name or the file name, the directory of the file needs to be in double quotation “”. The folder name and the file name are not case sensitive.

eg.

copy one file

data a;
b= system( 'copy "X:\Work\CPR\1617\1617 ROTA.pdf" X:\Work\CPR\1617\1617rota.pdf' );
run;

 

copy certain file type

data a;
b= system (' copy "x:\sas\project\new data\*.csv" "x:\sas\project\processed data\" ');
run; 

move certain file type

data a;
b= system (' move "x:\sas\project\new data\*.csv" "x:\sas\project\processed data\" ');
run;