Hello,
I have 694 observations in my file and I am doing a call execute.
However, the log file never goes until the end. So I am not able to confirm that every thing was fine.
How to solve that issue.
%macro dscleanup(env);
proc printto log="/dwh_actuariat/sasdata/Data_Retention/Validation/log/dscleanup.log" new;
%put &=env;
libname src1 spde "/.../Data_Retention_list/&env./";
libname src2 base "/.../SpecialPrjcts/Data_Retention/data/&env/";
data **bleep**rmt_in_premds_intg_20241031;
set src1.**bleep**rmt_in_premds_intg_20241031;
run;
data src1.listofdatasetstocleanup;
set src1.listofdatasetstocleanup;
run;
proc format;
value $alt_folder
'auto' = 'auto'
'prop' = 'habi'
'entr' = 'entr'
;
run;
proc format;
value $alt_prefix
'auto' = 'auto'
'prop' = 'prop'
'entr' = 'gc_cna'
;
run;
data src1.listofdatasetstocleanup2;
set src1.listofdatasetstocleanup;
cie=substr(filename,1,2);
lob=substr(filename,4,4);
month=substr(filename,12,3);
year=substr(filename,15,4);
folder=put(lob,alt_folder.);
run;
/*data masterlist_policy_20241031;*/
/*set src2.masterlist_policy_20241031;*/
/*run;*/
%macro doit(filename,year,month,cie, lob,folder);
%let path1=/dwh_actuariat/sasdata/Data_Retention;
%let path2=/dwh_actuariat/sasdata/Data_Retention/Data_Retention_CleanFiles;
%let path3=/dwh_actuariat/sasdata/Data_Retention/Data_Retention_Anonymized;
%put "&path1./sas&year./&cie./&folder." ;
%put "&path2./sas&year./&cie./&folder." ;
%put "&path3./sas&year./&cie./&folder." ;
/*libname source4 spde "&path1./sas&year./&cie./&folder." ;*/
/*libname dest1 spde "&path2./sas&year./&cie./&folder." ;*/
/*libname dest2 spde "&path3./sas&year./&cie./&folder." ;*/
/*data dest1.&fname dest2.&fname._Anonym;*/
/* merge source4.&fname. (in=inbase)*/
/* src2.masterlist_policy_20241031 (in=inlist)*/
/* ;*/
/* by ORGNL_SAS_DS_ROW_NBR;*/
/* if inlist and inbase then output dest2.&fname._Anonym;*/
/* else if inbase then output dest1.&fname.;*/
/*run;*/
/*libname source4 clear;*/
/*libname dest1 clear;*/
/*libname dest2 clear;*/
%mend doit;
data test;
set src1.listofdatasetstocleanup2;
run;
data _null_;
set src1.listofdatasetstocleanup2;
call execute(cats('%nrstr(%doit)(',filename
,',',year
,',',month
,',',cie
,',',lob
,',',folder,')'))
;
run;
%exit: %mend dscleanup;
%dscleanup(intg);
End of the log file:
677 + %doit(gc_auto_prmmar2015,2015,mar,gc,auto,auto)
"/dwh_actuariat/sasdata/Data_Retention/sas2015/gc/auto"
"/dwh_actuariat/sasdata/Data_Retention/Data_Retention_CleanFiles/sas2015/gc/auto"
"/dwh_actuariat/sasdata/Data_Retention/Data_Retention_Anonymized/sas2015/gc/auto"
678 + %doit(gc_auto_prmnov2015,2015,nov,gc,auto,auto)
51 The SAS System 16:25 Friday, November 22, 2024
"/dwh_actuariat/sasdata/Data_Retention/sas2015/gc/auto"
"/dwh_actuariat/sasdata/Data_Retention/Data_Retention_CleanFiles/sas2015/gc/auto"
"/dwh_actuariat/sasdata/Data_Retention/Data_Retention_Anonymized/sas2015/gc/auto"
679 + %doit(gc_auto_prmoct2015,2015,oct,gc,auto,auto)
"/dwh_actuariat/sasdata/Data_Retention/sas2015/gc/auto"
"/dwh_actuariat/sasdata/Data_Retention/Data_Retention_CleanFiles/sas2015/gc/auto"
"/dwh_actuariat/sasdata/Data_Retention/Data_Retention_Anonymized/sas2015/gc/auto"
680 + %doit(gc_auto_prmsep2015,2015,sep,gc,auto,auto)
"/dwh_actuariat/sasdata/Data_Retention/sas2015
How to solve that issue ?
Either you have hit something that is causing SAS to stop.
It could have something to do with what ever %DOIT() is doing for the place it stops. If so you might want to try running the job with the system option that makes it not buffer writes to the LOG so you can see better where it died. If you are starting SAS from the command line try adding this option
-logparm 'write=immediate'
For example perhaps the actual values you used to generate the code you pushed to the stack to run has unbalanced quotes or parentheses. Can you browse the data and check for quotes or () in the values of those variables?
Or perhaps you have just exceeded the number of bytes of code you can stack with CALL EXECUTE. Try switching to write the generated code to a file instead. That will actually make it easier to check the last two possibilities as you can LOOK at the code before you run it.
You should also move the definition of the macro %DOIT out of the middle of the definition of the other macro. Why would you want to force SAS to redefine %DOIT every time you execute %DSCLEANUP?
/* Generate code to a temporary file. */
filename code temp;
data _null_;
set src1.listofdatasetstocleanup2;
file code;
put
'%doit(' filename=
',' year=
',' month=
',' cie=
',' lob=
',' folder=
')'
;
run;
/* Run this step to copy the generated code to the log */
data _null_;
infile code;
input;
put _infile_;
run;
/* Run this statement to execute the generated code */
%include code / source2;
I've experienced in the past issues with the use of call execute() within a SAS macro. You could use dosubl() instead. I personally prefer to generate and %include code the way @Tom already demonstrated because it leads to SAS log that's easier to read and debug.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.