BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

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: ***********

1 ACCEPTED SOLUTION

Accepted Solutions
gauravkodmalwar
Calcite | Level 5

Since I am a newbie to SAS so off course I couldn't solve the problem but I could search the solution on google Smiley Happy

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;

View solution in original post

7 REPLIES 7
jakarman
Barite | Level 11

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.

---->-- ja karman --<-----
gauravkodmalwar
Calcite | Level 5

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.

Kurt_Bremser
Super User

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".

gauravkodmalwar
Calcite | Level 5

Since I am a newbie to SAS so off course I couldn't solve the problem but I could search the solution on google Smiley Happy

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;

jakarman
Barite | Level 11

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. 

---->-- ja karman --<-----

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1078 views
  • 2 likes
  • 4 in conversation