DATA Step, Macro, Functions and more

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?

Accepted Solution Solved
Reply
Contributor
Posts: 28
Accepted Solution

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?

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


Accepted Solutions
Solution
‎02-06-2015 04:27 AM
Contributor
Posts: 28

Re: 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?

Posted in reply to gauravkodmalwar

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


All Replies
Trusted Advisor
Posts: 3,215

Re: 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?

Posted in reply to gauravkodmalwar

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 --<-----
Contributor
Posts: 28

Re: 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?

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.

Super User
Posts: 7,832

Re: 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?

Posted in reply to gauravkodmalwar

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

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 28

Re: 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?

Posted in reply to KurtBremser

Thanks Kurt, tried same thing but didn't help it. It's still working same way.

Solution
‎02-06-2015 04:27 AM
Contributor
Posts: 28

Re: 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?

Posted in reply to gauravkodmalwar

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;

Trusted Advisor
Posts: 3,215

Re: 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?

Posted in reply to gauravkodmalwar

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 Super FREQ
Posts: 3,755

Re: 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?

Posted in reply to gauravkodmalwar

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

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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