Pular para conteúdo

2020

Comparar bases no SAS

Já tive a necessidade de compara duas tabelas geradas campo a campo para saber se eram iguais.

proc sort data =TABELA_A;
 by COLUNA1 COLUNA2;
run;


proc sort data = TABELA_B;
 by COLUNA1 COLUNA2;
run; 


proc compare
 base=TABELA_A
 compare=TABELA_B listall;
 COLUNA1 COLUNA2;
run;

Buscar tabela mais recente por sufixo

Ao armazenar tabelas no formato TABELA_ANOMES (TABELA_202001, TABELA_202002 ...) tem-se a necessidade de buscar a tabela do mês mais recente.

1
2
3
4
5
6
proc sql noprint;
    select max(scan(memname,4,'_')) into :date
    from dictionary.tables
    where 
        libname = upcase("MEU_LOCAL") and memname like 'TABELA_%';
quit;