Hi
I'm using this macro to copy qlikview files with folder structure from one location to the other
%macro qvwrobocopydir (dir, archive);
%let datum = %sysfunc(date(),date7.);
filename kopie pipe "robocopy %superq(dir) %superq(archive) *.qvw /MIR /Z /LOG:%superq(archive)\robocopy_&datum..log";
data _null_;
infile kopie;
input;
put _infile_;
run;
%mend;
%qvwrobocopydir(f:\mainroot\Research & Development, g:\PROD\qvw_backup);
Despite the fact the folder f:\mainroot\Research & Development is used within the superq function the copy does not take place.
The & in the folder is the showstopper.
What can I do to circumvent this ? I already tried %nrstr( but this does not help either.
Also I have access to both paths.
Any suggestions ?
Thanks
B
I think you need to pass the quotes down to the DOS command (when you invoke the macro) for the path spec to be formatted for Windows. Here's the code snippet I tried:
1 %macro qvwrobocopydir (dir, archive); 2 %let datum = %sysfunc(date(),date7.); 3 filename kopie pipe "robocopy %superq(dir) %superq(archive) *.qvw /MIR /NP"; 4 data _null_; 5 infile kopie; 6 input; 7 put _infile_; 8 run; 9 %mend; 10 %qvwrobocopydir("C:\temp\R & D", "C:\temp\backup"); NOTE: The infile KOPIE is: Unnamed Pipe Access Device, PROCESS=robocopy "C:\temp\R & D" "C:\temp\backup" *.qvw /MIR /NP, RECFM=V,LRECL=32767 ------------------------------------------------------------------------------- ROBOCOPY :: Robust File Copy for Windows ------------------------------------------------------------------------------- Started : Thursday, February 15, 2018 2:43:19 PM Source : C:\temp\R & D\ Dest : C:\temp\backup\ Files : *.qvw Options : /S /E /DCOPY:DA /COPY:DAT /PURGE /MIR /NP /R:1000000 /W:30 ------------------------------------------------------------------------------ 3 C:\temp\R & D\ New File 14378 test1.qvw New File 104890 test2.qvw New File 100536 test3.qvw ------------------------------------------------------------------------------ Total Copied Skipped Mismatch FAILED Extras Dirs : 1 0 1 0 0 0 Files : 3 3 0 0 0 0 Bytes : 214.6 k 214.6 k 0 0 0 0 Times : 0:00:00 0:00:00 0:00:00 0:00:00 Speed : 24422666 Bytes/sec. Speed : 1397.476 MegaBytes/min. Ended : Thursday, February 15, 2018 2:43:19 PM NOTE: 33 records were read from the infile KOPIE. The minimum record length was 0. The maximum record length was 81. NOTE: DATA statement used (Total process time): real time 0.11 seconds user cpu time 0.00 seconds system cpu time 0.01 seconds memory 1086.53k OS Memory 9196.00k Timestamp 02/15/2018 02:43:19 PM Step Count 1 Switch Count 0
Well, I hate to point out the obvious, but putting special characters in paths is a pretty bad thing to do from both programming an system point of view. Maxim 44:
As a note, you could just stream text files through a datastep to effect a copy.
Look up the FCOPY function.
@Billybob73 wrote:
Hi
I'm using this macro to copy qlikview files with folder structure from one location to the other
%macro qvwrobocopydir (dir, archive);
%let datum = %sysfunc(date(),date7.);
filename kopie pipe "robocopy %superq(dir) %superq(archive) *.qvw /MIR /Z /LOG:%superq(archive)\robocopy_&datum..log";
data _null_;
infile kopie;
input;
put _infile_;
run;
%mend;
%qvwrobocopydir(f:\mainroot\Research & Development, g:\PROD\qvw_backup);
Despite the fact the folder f:\mainroot\Research & Development is used within the superq function the copy does not take place.
The & in the folder is the showstopper.
What can I do to circumvent this ? I already tried %nrstr( but this does not help either.
Also I have access to both paths.
Any suggestions ?
Thanks
B
I think you need to pass the quotes down to the DOS command (when you invoke the macro) for the path spec to be formatted for Windows. Here's the code snippet I tried:
1 %macro qvwrobocopydir (dir, archive); 2 %let datum = %sysfunc(date(),date7.); 3 filename kopie pipe "robocopy %superq(dir) %superq(archive) *.qvw /MIR /NP"; 4 data _null_; 5 infile kopie; 6 input; 7 put _infile_; 8 run; 9 %mend; 10 %qvwrobocopydir("C:\temp\R & D", "C:\temp\backup"); NOTE: The infile KOPIE is: Unnamed Pipe Access Device, PROCESS=robocopy "C:\temp\R & D" "C:\temp\backup" *.qvw /MIR /NP, RECFM=V,LRECL=32767 ------------------------------------------------------------------------------- ROBOCOPY :: Robust File Copy for Windows ------------------------------------------------------------------------------- Started : Thursday, February 15, 2018 2:43:19 PM Source : C:\temp\R & D\ Dest : C:\temp\backup\ Files : *.qvw Options : /S /E /DCOPY:DA /COPY:DAT /PURGE /MIR /NP /R:1000000 /W:30 ------------------------------------------------------------------------------ 3 C:\temp\R & D\ New File 14378 test1.qvw New File 104890 test2.qvw New File 100536 test3.qvw ------------------------------------------------------------------------------ Total Copied Skipped Mismatch FAILED Extras Dirs : 1 0 1 0 0 0 Files : 3 3 0 0 0 0 Bytes : 214.6 k 214.6 k 0 0 0 0 Times : 0:00:00 0:00:00 0:00:00 0:00:00 Speed : 24422666 Bytes/sec. Speed : 1397.476 MegaBytes/min. Ended : Thursday, February 15, 2018 2:43:19 PM NOTE: 33 records were read from the infile KOPIE. The minimum record length was 0. The maximum record length was 81. NOTE: DATA statement used (Total process time): real time 0.11 seconds user cpu time 0.00 seconds system cpu time 0.01 seconds memory 1086.53k OS Memory 9196.00k Timestamp 02/15/2018 02:43:19 PM Step Count 1 Switch Count 0
Thanks Dave ! This works !
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.