filename invokes catalog 'work.formats.invokes.source'; data _null_; infile cards dlm=',' missover; length format range1 range2 $60; input format range1 range2; file invokes; if format ne ''; if range2 ne '' then put '%xw (' format= ',' range1= ',' range2= ')'; else put '%w (' format= ',' range1= ')'; cards; DATEw., 5 to 9 DAYw., 3 to 32 DDMMYYw., 2 to 10 DDMMYYxw., BCDNPS, 2 to 10 DOWNAMEw., 1 to 32 EURDFDDw., 2 to 8 EURDFDEw., 5 to 9 EURDFDNw., 1 to 32 EURDFDWNw., 1 to 32 EURDFMNw., 1 to 32 EURDFMYw., 5 to 7 EURDFWDXw., 17 to 32 * varies by dflang EURDFWKXw., 3 to 37 * varies by dflang JULDAYw., 3 to 32 JULIANw., 5 to 7 MINGUOw., 1 to 10 MMDDYYw., 2 to 8 MMDDYYxw., BCDNPS, 2 to 10 MMYYw., 5 to 32 MMYYxw., CDNPS, 5 to 32 MONNAMEw., 1 to 32 MONTHw., 1 to 21 MONYYw., 5 to 7 NENGOw., 2 to 10 PDJULGw., 3 to 16 PDJULIw., 3 to 16 QTRw., 1 to 32 QTRRw., 3 to 32 WEEKDATEw., 3 to 37 WEEKDATXw., 3 to 37 WEEKDAYw., 1 to 32 WORDDATEw., 3 to 32 WORDDATXw., 3 to 32 YEARw., 2 to 32 YYMMw., 5 to 32 YYMMxw., CDNPS, 5 to 32 YYMMDDw., 2 to 8 YYMMDDxw., BCDNPS, 2 to 10 YYMONw., 5 to 32 YYQw., 4 to 32 YYQxw., CDNPS, 4 to 32 YYQRw., 6 to 32 YYQRxw., CDNPS, 6 to 32 ; run; %macro xw (format=, range1=, range2=); %let fmt = %sysfunc (tranwrd(&format,xw.,.)); put ; put "&fmt" @12 '-> ' date &fmt; %do i = 1 %to %length(&range1); %let x = %substr(&range1,&i,1); %let A = %scan (&range2,1); %let B = %scan (&range2,3); %if &x = N and (&format=YYMMDDxw. or &format=MMDDYYxw. or &format=DDMMYYxw.) %then %let B = %eval(&B-2); %do j = &A %to &B; %let fmt = %sysfunc(tranwrd(&format,xw.,&x.&j..)); put "&fmt" @12 '-> ' date &fmt; %end; %end; %mend; %macro w (format=, range1=); %let fmt = %sysfunc (tranwrd(&format,w.,.)); put ; put "&fmt" @12 '-> ' date &fmt; %let A = %scan (&range1,1); %let B = %scan (&range1,3); %do i = &A %to &B; %let fmt = %sysfunc(tranwrd(&format,w,&i)); put "&fmt" @12 '-> ' date &fmt; %end; %mend; options source2 mprint; options nosource2 nomprint; data _null_; date = today(); %include invokes; run;