Not all files copied to new location using following code, only 105 log files are copied to new location out of 145 files. Following is code & output. Any idea what's blocking it? Is it somewhere setting to limit number of objects to copy?
********* SAS code: *********
%macro userwritten_copy(src=,dst=);
filename mycopy pipe "copy &src\*.* &dst\*.*";
data copydir;
infile mycopy;
run;
%mend userwritten_copy;
********* SAS code: *********
********* SAS log: ***********
NOTE: The infile MYCOPY is:
Unnamed Pipe Access Device,
PROCESS=copy
sourcepath\*.*
destpath\*.*,
RECFM=V,LRECL=1024
NOTE: 0 records were read from the infile MYCOPY.
NOTE: The data set WORK.COPYDIR has 1 observations and 0 variables.
NOTE: DATA statement used (Total process time):
real time 2:00.00
cpu time 0.04 seconds
********* SAS log: ***********
Since I am a newbie to SAS so off course I couldn't solve the problem but I could search the solution on google
Following solution worked out, I think 'stdout' solved the problem.
%macro userwritten_copy(src=,dst=);
filename mycopy pipe "copy &src.\*.* &dst.";
data copydir;
/*input put &dst. ;
input;
stdout=&dst.;*/
infile mycopy;
input;
stdout="&dst.";
run;
%mend userwritten_copy;
add: "input put _infile_ ;" to your datastep it will show the messages of the executed program.
Most likely there are some and they are telling you the reason.
Thanks Jaap, I am very new to SAS so I could use it like following instead of mentioned 'input put _infile_ ;'.
input;
put _infile_ ;
It was throwing error: ERROR: The _INFILE_ variable cannot be referenced by the INPUT statement.
But I couldn't understand the difference in logs, may be I am new to this. But thanks, surely useful in DATA steps once I start working further.
Try using "copy &src.\*.* &dst." in the filename pipe (witout the *.* in the destination!). It may be that the expansion of dst\*.* causes confusion (a similar command in UNIX like cp src/*.* dst/*.* would not do anything at all if the last file found by dst/*.* was not a directory!). Also note that it is good practice to terminate macro variable names with a dot when the macro variables are used as part of a "word".
Thanks Kurt, tried same thing but didn't help it. It's still working same way.
Since I am a newbie to SAS so off course I couldn't solve the problem but I could search the solution on google
Following solution worked out, I think 'stdout' solved the problem.
%macro userwritten_copy(src=,dst=);
filename mycopy pipe "copy &src.\*.* &dst.";
data copydir;
/*input put &dst. ;
input;
stdout=&dst.;*/
infile mycopy;
input;
stdout="&dst.";
run;
%mend userwritten_copy;
Sorry for not being complete.
%macro userwritten_copy(src=,dst=);
filename mycopy pipe "copy &src.\*.* &dst. 2>&1"; /* Redirecting Error Messages from Command Prompt: STDERR/STDOUT the 2&>1 is the errorfile redirection */
data _null_ ; /* there is no need for a sas-datset _null_ will do */
infile mycopy; input; put _infile_ ; /* all semicolons must be at correct positions. The messages and error message should be got and printed. */
run; /* 1/ open the file to execute 2/ read every line 3/ print that line */
Having problems with Windows batch files or command try those first in a Windows command-window. Badly name as a dos-box.
This has nothing to do with SAS/IML. In the future please post questions like this to the "Macro and DATA Step" community: https://communities.sas.com/community/support-communities/sas_macro_facility_data_step_and_sas_langu...
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.