Thank you both!
I added symbolgen mprint in the options and replaced %put with put and displayed report_name and suffix.
Here is my modified code and log:
%macro Archive(path,duration,npath);
options mprint symbolgen;
*Filename Files pipe %unquote(%str(%') cd "&path." %str(%'));
Filename Files PIPE %unquote(%str(%') cd"&path." /b %str(%'));
*Filename Files PIPE %unquote(%str(%') dir "&path." %str(%'));
%put %unquote(%str(%') cd "&path." %str(%'));
%put %unquote(%str(%') cd"&path." /b %str(%'));
%put %unquote(%str(%') dir "&path." %str(%'));
data List;
infile Files lrecl=100 truncover;
input Full_Name $100.;
dur=&duration.;
Report_Name=strip(scan(Full_Name, 1, "."));
put'Report_name:' report_name;
Suffix=strip(scan(Full_Name, 3, "."));
put 'Suffix:' suffix;
N=length(Report_Name);
MTH_Year=strip(substr(Report_Name, N-7));
DD_MTH_Year=substr(MTH_YEAR, 7,2)||substr(MTH_YEAR, 5, 2)||substr(MTH_YEAR, 1, 4);
ddmmy=input(dd_mth_year,anydtdte8.);
Age=INTCK("Month",ddmmy,today());
run;
data _null_;
length Old_Name New_Name $100;
set List;
if Age > &Duration. then
do;
Old_Name="&path."||strip(Full_Name);
%put old_name;
New_Name="&npath."||strip(Full_Name);
%put new_name;
RC=rename(Old_Name, New_Name, 'file');
%put 'RC:' RC;
if RC=0 then
put "Note: Files moved to Archive folder: " Old_Name;
else put "Note: Files cannot be moved: " Old_Name;
end;
run;
%mend;
%archive(/apps/sas/datasets/data7/scbsr/code/teamr/test/vv,5,/apps/sas/datasets/data7/scbsr/code/teamr/test/vv1)
Log:
1 %_eg_hidenotesandsource;
MPRINT(_EG_HIDENOTESANDSOURCE): options nonotes;
MPRINT(_EG_HIDENOTESANDSOURCE): options nosource;
SYMBOLGEN: Macro variable _EGNOTES resolves to NOTES
MPRINT(_EG_RESTORENOTESANDSOURCE): options NOTES;
SYMBOLGEN: Macro variable _EGSOURCE resolves to SOURCE
MPRINT(_EG_RESTORENOTESANDSOURCE): options SOURCE;
5 %_eg_hidenotesandsource;
MPRINT(_EG_HIDENOTESANDSOURCE): options nonotes;
MPRINT(_EG_HIDENOTESANDSOURCE): options nosource;
SYMBOLGEN: Macro variable SASWORKLOCATION resolves to
"/apps/sas/datasets/temp01/SAS_work676B01870076_nzapap68/SAS_work6D2401870076_nzapap68/"
SYMBOLGEN: Macro variable _EGNOTES resolves to NOTES
MPRINT(_EG_RESTORENOTESANDSOURCE): options NOTES;
SYMBOLGEN: Macro variable _EGSOURCE resolves to SOURCE
MPRINT(_EG_RESTORENOTESANDSOURCE): options SOURCE;
28
29 %macro Archive(path,duration,npath);
30 options mprint symbolgen;
31 *Filename Files pipe %unquote(%str(%') cd "&path." %str(%'));
32 Filename Files PIPE %unquote(%str(%') cd"&path." /b %str(%'));
33 *Filename Files PIPE %unquote(%str(%') dir "&path." %str(%'));
34
35 %put %unquote(%str(%') cd "&path." %str(%'));
36 %put %unquote(%str(%') cd"&path." /b %str(%'));
37 %put %unquote(%str(%') dir "&path." %str(%'));
38
39 data List;
40 infile Files lrecl=100 truncover;
41 input Full_Name $100.;
42 dur=&duration.;
43 Report_Name=strip(scan(Full_Name, 1, "."));
44 put'Report_name:' report_name;
45 Suffix=strip(scan(Full_Name, 3, "."));
46 put 'Suffix:' suffix;
47 N=length(Report_Name);
48 MTH_Year=strip(substr(Report_Name, N-7));
49 DD_MTH_Year=substr(MTH_YEAR, 7,2)||substr(MTH_YEAR, 5, 2)||substr(MTH_YEAR, 1, 4);
50 ddmmy=input(dd_mth_year,anydtdte8.);
51 Age=INTCK("Month",ddmmy,today());
52 run;
53
54 data _null_;
55 length Old_Name New_Name $100;
56 set List;
57
58 if Age > &Duration. then
59 do;
60 Old_Name="&path."||strip(Full_Name);
61 %put old_name;
62 New_Name="&npath."||strip(Full_Name);
63 %put new_name;
64 RC=rename(Old_Name, New_Name, 'file');
65 %put 'RC:' RC;
66
67 if RC=0 then
68 put "Note: Files moved to Archive folder: " Old_Name;
69 else put "Note: Files cannot be moved: " Old_Name;
2 The SAS System 20:18 Thursday, February 16, 2017
70 end;
71 run;
72
73 %mend;
74
75 %archive(/apps/sas/datasets/data7/scbsr/code/team/test/vv,5,/apps/sas/datasets/data7/scbsr/code/team/te
75 ! st/vv1)
MPRINT(ARCHIVE): options mprint symbolgen;
MPRINT(ARCHIVE): *Filename Files pipe %unquote(' cd "&path." ');
SYMBOLGEN: Macro variable PATH resolves to /apps/sas/datasets/data7/scbsr/code/team/test/vv
MPRINT(ARCHIVE): Filename Files PIPE ' cd"/apps/sas/datasets/data7/scbsr/code/team/test/vv" /b ';
MPRINT(ARCHIVE): *Filename Files PIPE %unquote(' dir "&path." ');
SYMBOLGEN: Macro variable PATH resolves to /apps/sas/datasets/data7/scbsr/code/team/test/vv
' cd "/apps/sas/datasets/data7/scbsr/code/team/test/vv" '
SYMBOLGEN: Macro variable PATH resolves to /apps/sas/datasets/data7/scbsr/code/team/test/vv
' cd"/apps/sas/datasets/data7/scbsr/code/team/test/vv" /b '
SYMBOLGEN: Macro variable PATH resolves to /apps/sas/datasets/data7/scbsr/code/team/test/vv
' dir "/apps/sas/datasets/data7/scbsr/code/team/test/vv" '
MPRINT(ARCHIVE): data List;
MPRINT(ARCHIVE): infile Files lrecl=100 truncover;
MPRINT(ARCHIVE): input Full_Name $100.;
SYMBOLGEN: Macro variable DURATION resolves to 5
MPRINT(ARCHIVE): dur=5;
MPRINT(ARCHIVE): Report_Name=strip(scan(Full_Name, 1, "."));
MPRINT(ARCHIVE): put'Report_name:' report_name;
MPRINT(ARCHIVE): Suffix=strip(scan(Full_Name, 3, "."));
MPRINT(ARCHIVE): put 'Suffix:' suffix;
MPRINT(ARCHIVE): N=length(Report_Name);
MPRINT(ARCHIVE): MTH_Year=strip(substr(Report_Name, N-7));
MPRINT(ARCHIVE): DD_MTH_Year=substr(MTH_YEAR, 7,2)||substr(MTH_YEAR, 5, 2)||substr(MTH_YEAR, 1, 4);
MPRINT(ARCHIVE): ddmmy=input(dd_mth_year,anydtdte8.);
MPRINT(ARCHIVE): Age=INTCK("Month",ddmmy,today());
MPRINT(ARCHIVE): run;
NOTE: The infile FILES is:
Pipe command="cd"/apps/sas/datasets/data7/scbsr/code/team/test/vv" /b "
Report_name:/usr/bin/ksh: cd/apps/sas/datasets/data7/scbsr/code/team/test/vv: not found
Suffix:
NOTE: 1 record was read from the infile FILES.
The minimum record length was 85.
The maximum record length was 85.
NOTE: Missing values were generated as a result of performing an operation on missing values.
Each place is given by: (Number of times) at (Line):(Column).
1 at 75:190
NOTE: The data set WORK.LIST has 1 observations and 9 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds
MPRINT(ARCHIVE): data _null_;
MPRINT(ARCHIVE): length Old_Name New_Name $100;
MPRINT(ARCHIVE): set List;
SYMBOLGEN: Macro variable DURATION resolves to 5
MPRINT(ARCHIVE): if Age > 5 then do;
SYMBOLGEN: Macro variable PATH resolves to /apps/sas/datasets/data7/scbsr/code/team/test/vv
MPRINT(ARCHIVE): Old_Name="/apps/sas/datasets/data7/scbsr/code/team/test/vv"||strip(Full_Name);
3 The SAS System 20:18 Thursday, February 16, 2017
old_name
SYMBOLGEN: Macro variable NPATH resolves to /apps/sas/datasets/data7/scbsr/code/team/test/vv1
MPRINT(ARCHIVE): New_Name="/apps/sas/datasets/data7/scbsr/code/team/test/vv1"||strip(Full_Name);
new_name
MPRINT(ARCHIVE): RC=rename(Old_Name, New_Name, 'file');
'RC:' RC
MPRINT(ARCHIVE): if RC=0 then put "Note: Files moved to Archive folder: " Old_Name;
MPRINT(ARCHIVE): else put "Note: Files cannot be moved: " Old_Name;
MPRINT(ARCHIVE): end;
MPRINT(ARCHIVE): run;
NOTE: There were 1 observations read from the data set WORK.LIST.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
Thank you!
... View more