Pular para conteúdo

2025

Include condicional

Condicional include

%if &syscc > 4 %then %do;
  %inc "/mypath/pgmB.sas";
%end;
%else %do;
  %inc "/mypath/pgmA.sas";
%end;

Laço em macro

Laço em macro

/* Define the library name */
libname mylib 'path-to-your-library';

/* Get the list of all tables in the library */
proc sql noprint;
    select memname into :table_list separated by ' '
    from dictionary.tables
    where libname = 'MYLIB';
quit;

/* Macro to export each table to an Excel file */
%macro export_tables;
    %let count = %sysfunc(countw(&table_list));
    %do i = 1 %to &count;
        %let table = %scan(&table_list, &i);
        proc export data=mylib.&table
            outfile="path-to-your-directory/&table..xlsx"
            dbms=xlsx replace;
        run;
    %end;
%mend export_tables;

/* Run the macro */
%export_tables;