BookmarkSubscribeRSS Feed
wrosario
Calcite | Level 5

/* INICIO CONTROLE DE CARGA INCREMENTAL E INICIAL  */

%macro test;

PROC SQL;

    CREATE TABLE TMP_SIAR.W1ZZ34(

        NUMFUNC NUM FORMAT = 10. INFORMAT = 10. ,

        NUMVINC NUM FORMAT = 9. INFORMAT = 9. ,

        DTINI NUM FORMAT = DATETIME20. INFORMAT = DATETIME20. ,

        DTFIM NUM FORMAT = DATETIME20. INFORMAT = DATETIME20. ,

        FUNCAO NUM FORMAT = 7. INFORMAT = 7. ,

        SETOR CHAR(15) FORMAT = $15. INFORMAT = $15.,

        EMP_CODIGO NUM FORMAT = 3. INFORMAT = 3. ,

        SK_NUM_PROCESSO_JOB NUM);

  SELECT COUNT(1) AS CONT1 INTO :CONT1 FROM SIAR_CGA.CONTROLE_CARGA_JOBS WHERE COD_UNI_JOB IN (1,3);

  SELECT COUNT(1) AS TAB1 INTO :TAB1 FROM FAT_SIAR.FAT_PROV_DESIG_SUBST WHERE COD_ORIGEM_TABELA  = 1;

QUIT;

%IF &CONT1=0 %THEN %DO;

    %IF &TAB1=0 %THEN %DO;

        PROC SQL PRINT;

            INSERT INTO TMP_SIAR.W1ZZ34

            SELECT

                ODS_DESIGNACOES_EV.NUMFUNC,

                ODS_DESIGNACOES_EV.NUMVINC,

                ODS_DESIGNACOES_EV.DTINI,

                ODS_DESIGNACOES_EV.DTFIM,

                ODS_DESIGNACOES_EV.FUNCAO,

                ODS_DESIGNACOES_EV.SETOR,

                ODS_DESIGNACOES_EV.EMP_CODIGO,

                0 AS SK_NUM_PROCESSO_JOB

            FROM ODS_SIAR.ODS_DESIGNACOES_EV AS ODS_DESIGNACOES_EV INNER JOIN

                 DIM_SIAR.DIM_VINCULO AS DIM_VINCULO

            ON

            (

                ODS_DESIGNACOES_EV.NUMFUNC = DIM_VINCULO.NUM_SERVIDOR

                AND ODS_DESIGNACOES_EV.NUMVINC = DIM_VINCULO.NUM_VINCULO

                AND ODS_DESIGNACOES_EV.EMP_CODIGO = DIM_VINCULO.COD_EMPRESA

            );

        QUIT;

    %END;

%END;         

   %ELSE %DO;

    PROC SQL PRINT;

   

            INSERT INTO TMP_SIAR.W1ZZ34

            SELECT

                ODS_DESIGNACOES_EV.NUMFUNC,

                ODS_DESIGNACOES_EV.NUMVINC,

                ODS_DESIGNACOES_EV.DTINI,

                ODS_DESIGNACOES_EV.DTFIM,

                ODS_DESIGNACOES_EV.FUNCAO,

                ODS_DESIGNACOES_EV.SETOR,

                ODS_DESIGNACOES_EV.EMP_CODIGO,

                CONTROLE_CARGA_JOBS.SK_NUM_PROCESSO_JOB

            FROM

                ODS_SIAR.ODS_DESIGNACOES_EV AS ODS_DESIGNACOES_EV

                INNER JOIN DIM_SIAR.DIM_VINCULO AS DIM_VINCULO

                ON

                (

                    ODS_DESIGNACOES_EV.NUMFUNC = DIM_VINCULO.NUM_SERVIDOR

                    AND ODS_DESIGNACOES_EV.NUMVINC = DIM_VINCULO.NUM_VINCULO

                    AND ODS_DESIGNACOES_EV.EMP_CODIGO = DIM_VINCULO.COD_EMPRESA

                )

                INNER JOIN SIAR_CGA.CONTROLE_CARGA_JOBS AS CONTROLE_CARGA_JOBS

                ON

                (

                     CONTROLE_CARGA_JOBS.NUM_SERVIDOR = ODS_DESIGNACOES_EV.NUMFUNC

                   AND CONTROLE_CARGA_JOBS.NUM_VINCULO = ODS_DESIGNACOES_EV.NUMVINC

                    AND CONTROLE_CARGA_JOBS.COD_UNI_JOB IN (1,3)

                );

    QUIT;

%END;

%mend test;

3 REPLIES 3
ballardw
Super User

And the question is???

wrosario
Calcite | Level 5

Friend, I am running a macro in DI or Guide and neither he is entering the data in the table


to perform separate command by command, works ... I think it may be something in the IF, already checked the tables and the same are loaded

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

Might I suggest some debugging.  I.e.

options mlogic mprint symbolgen source source2; 

Run it, find out what errors/warnings come up.  Then look at the code causing it, what do the macro variables resolve to etc.  We can see nothing from the code you have posted, as we don't know your data.  What happens when you run just the first proc sql, what macro variables are created?

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 832 views
  • 0 likes
  • 3 in conversation