Pessoal, eu estou rodando uma query no SAS e está dando um erro.
Já rodei outras códigos com os mesmos Where e funcionou, pode ser que eu esteja fazendo algum JOIN errado, ainda sou novo e estou tentando descobrir qual é a chave de cada tabela.
O Código:
PROC SQL;
CREATE TABLE WORK.QUERY_FOR_TB_DIM_UNDE_SCD AS
SELECT
t1.DS_ORIGEM,
t1.DS_CANAL,
t1.DS_UNIDADE_MKT,
t1.DS_REGIONAL,
t1.DS_GERENTE_SENIOR,
t1.DS_DIRETOR,
t1.DS_SUPERVISOR,
t1.DS_GRUPO_ECONOMICO,
t2.DS_CURSO_MKT,
t3.FL_BOLETO_PAGO,
t3.FL_BOLETO_DISPONIVEL,
t3.DT_PAGAMENTO,
t4.CD_CANDIDATO,
t4.CD_MATRICULA,
t4.CD_CURSO_1_OPC,
t4.DS_MODALIDADE,
t4.CD_POLO,
t4.DT_INSCRICAO,
t5.DS_SITUACAO_ACADEMICA,
t5.FL_PMA,
t5.FL_REMATRICULADO,
t5.DT_REMATRICULA
FROM ESDISTGS.TB_DIM_UNDE_SCD t1
INNER JOIN ESDISTGS.TB_DIM_CURSO t2 ON t1.DS_ORIGEM = t2.DS_SISTEMA_ORIGEM /*Ok*/
INNER JOIN ESDISTGS.TGT_BI_BOLETOS t3 ON t5.NR_CPF = t3.NR_CPF /*Ok*/
INNER JOIN ESDISTGS.TGT_BI_CAPTACAO_UNPR_GRAD t4 ON t1.CD_UNIDADE = t4.CD_POLO /*Ok*/
INNER JOIN ESDISTGS.TGT_BI_RETENCAO_ANALITICO t5 ON t1.DS_CANAL = t5.DS_CANAL
WHERE t5.DT_BASE = TODAY() - 1
AND t4.CD_MATRICULA = '45';
QUIT;
E esse é o erro que está dando:
ERROR: Expression using equals (=) has components that are of different data types.
INNER JOIN ESDISTGS.TB_DIM_CURSO t2 ON t1.DS_ORIGEM = t2.DS_SISTEMA_ORIGEM
If t1.DS_ORIGEM is numeric and t2.DS_SISTEMA_ORIGEM is character, or the other way around, this will cause the SQL to fail and produce the error message shown. It doesn't have to be this condition, you have 4 INNER JOINS and 2 WHERE conditions that could cause this error, there is no way for me to determine which of these is the problem. You can check to find which of these variables are numeric and which are character, and then you can fix the problem.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.