Advertisement
Guest User

Untitled

a guest
Nov 8th, 2018
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SAS 16.13 KB | None | 0 0
  1. /****************************************************************************
  2.  * Job:             JOB_STG_DIM_CONTRATO                  A561KEHC.BU0000YL *
  3.  * Description:                                                             *
  4.  *                                                                          *
  5.  * Metadata Server: dlcuzcoora1.mctp.corp                                   *
  6.  * Port:            8561                                                    *
  7.  * Location:        /User Folders/Emanuel Giannattasio/SPRINT_91/CAM1819    *
  8.  *                                                                          *
  9.  * Server:          SASApp                                A561KEHC.AT000002 *
  10.  *                                                                          *
  11.  * Source Tables:   Dim_Contrato - OLAP.Dim_Contrato      A561KEHC.BH000013 *
  12.  *                  Dim_Cliente - OLAP.Dim_Cliente        A561KEHC.BH000020 *
  13.  * Target Table:    STG_DIM_CONTRATO -                    A561KEHC.BH000015 *
  14.  *                   CM_STAGE.STG_DIM_CONTRATO                              *
  15.  *                                                                          *
  16.  * Generated on:    miércoles 26 de septiembre de 2018 14h'26 ART           *
  17.  * Generated by:    sasdemo@saspw                                           *
  18.  * Version:         SAS Data Integration Studio 4.901                       *
  19.  ****************************************************************************/
  20.  
  21. /* Generate the process id for job  */
  22. %put Process ID: &SYSJOBID.;
  23.  
  24. /* General macro variables  */
  25. %let jobID = %quote(A561KEHC.BU0000YL);
  26. %let etls_jobName = %nrquote(JOB_STG_DIM_CONTRATO);
  27. %let etls_userID = %nrquote(sasdemo@saspw);
  28.  
  29. /* Setup to capture return codes  */
  30. %global job_rc trans_rc sqlrc;
  31. %let sysrc = 0;
  32. %let job_rc = 0;
  33. %let trans_rc = 0;
  34. %let sqlrc = 0;
  35. %global etls_stepStartTime;
  36. /* initialize syserr to 0 */
  37. data _null_; run;
  38.  
  39. %macro rcSet(error);
  40.    %if (&error. gt &trans_rc.) %then
  41.       %let trans_rc = &error.;
  42.    %if (&error. gt &job_rc.) %then
  43.       %let job_rc = &error.;
  44. %mend rcSet;
  45.  
  46. %macro rcSetDS(error);
  47.    if &error. gt input(symget('trans_rc'),12.) then
  48.       call symput('trans_rc',trim(left(put(&error.,12.))));
  49.    if &error. gt input(symget('job_rc'),12.) then
  50.       call symput('job_rc',trim(left(put(&error.,12.))));
  51. %mend rcSetDS;
  52.  
  53. /* Create metadata macro variables */
  54. %let IOMServer      = %nrquote(SASApp);
  55. %let metaPort       = %nrquote(8561);
  56. %let metaServer     = %nrquote(dlcuzcoora1.mctp.corp);
  57.  
  58. /* Setup for capturing job status  */
  59. %let etls_startTime = %sysfunc(datetime(),datetime.);
  60. %let etls_recordsBefore = 0;
  61. %let etls_recordsAfter = 0;
  62. %let etls_lib = 0;
  63. %let etls_table = 0;
  64.  
  65. %global etls_debug;
  66. %macro etls_setDebug;
  67.    %if %str(&etls_debug.) ne 0 %then
  68.       OPTIONS MPRINT%str(;);
  69. %mend;
  70. %etls_setDebug;
  71.  
  72. /*---- Start of Pre-Process Code  ----*/
  73.  
  74. /*LIBNAME OLAP SQLSVR  Datasrc=SAS  SCHEMA=dbo  USER=USERSAS  PASSWORD="{SAS002}1D4896162487EAF8" ;*/
  75.  
  76. %validarFechaOlap(and);
  77.  
  78. data fechas;
  79.     fecha_inicio=intnx('day',date(),-90,'beginning');
  80. run;
  81.  
  82. proc sql noprint;
  83.     select fecha_inicio format=ddmmyy10. into :fecha_inicio  from fechas;
  84.  
  85. proc sql noprint;
  86. select fecha_key into :fecha_ini from olap.dim_fecha where dia = "&fecha_inicio.";
  87.  
  88. /*---- End of Pre-Process Code  ----*/
  89.  
  90. %rcSet(&syserr.);
  91. %rcSet(&sqlrc.);
  92.  
  93. /*==========================================================================*
  94.  * Step:            Join                                  A561KEHC.BW0001KI *
  95.  * Transform:       Join                                                    *
  96.  * Description:                                                             *
  97.  *                                                                          *
  98.  * Source Tables:   Dim_Contrato - OLAP.Dim_Contrato      A561KEHC.BH000013 *
  99.  *                  Dim_Cliente - OLAP.Dim_Cliente        A561KEHC.BH000020 *
  100.  * Target Table:    Join - work.WFM6STLY                  A561KEHC.BX0001AY *
  101.  *==========================================================================*/
  102.  
  103. %let transformID = %quote(A561KEHC.BW0001KI);
  104. %let trans_rc = 0;
  105. %let etls_stepStartTime = %sysfunc(datetime(), datetime20.);
  106.  
  107. %let etls_recnt = -1;
  108. %global etls_sql_pushDown;
  109. %let etls_sql_pushDown = -1;
  110. option DBIDIRECTEXEC;
  111.  
  112. proc datasets lib = work nolist nowarn memtype = (data view);
  113.    delete WFM6STLY;
  114. quit;
  115.  
  116. /*
  117. Path_Inc es una variable macro definida en appserver_autoexec.sas;
  118. /sasFiles/MA/bin/Parametros/sas
  119. */
  120.  
  121. %include "&Path_Inc./ctrlTablaVacia.sas";
  122.  
  123. %ctrlTablaVacia(OLAP, Dim_Contrato);
  124.  
  125. proc sql;
  126.    create view work.WFM6STLY as
  127.    select
  128.       Dim_Contrato.Contrato length = 8  
  129.          format = 11.
  130.          informat = 11.
  131.          label = 'Contrato',
  132.       Dim_Contrato.Contrato_Key length = 8  
  133.          format = 11.
  134.          informat = 11.
  135.          label = 'Contrato_Key',
  136.       Dim_Contrato.Estado_Parque_Key length = 8  
  137.          format = 4.
  138.          informat = 4.
  139.          label = 'Estado_Parque_Key',
  140.       Dim_Contrato.Estado_Suspension_Key length = 8  
  141.          format = 6.
  142.          informat = 6.
  143.          label = 'Estado_Suspension_Key',
  144.       Dim_Contrato.Fecha_Activacion_Key length = 8  
  145.          format = 6.
  146.          informat = 6.
  147.          label = 'Fecha_Activacion_Key',
  148.       Dim_Contrato.Linea length = 8  
  149.          format = 20.
  150.          informat = 20.
  151.          label = 'Linea',
  152.       Dim_Contrato.Localidad_Anterior_Key length = 8  
  153.          format = 11.
  154.          informat = 11.
  155.          label = 'Localidad_Anterior_Key',
  156.       Dim_Contrato.Localidad_Key length = 8  
  157.          format = 11.
  158.          informat = 11.
  159.          label = 'Localidad_Key',
  160.       Dim_Contrato.Segmento_CRM_Key length = 8  
  161.          format = 6.
  162.          informat = 6.
  163.          label = 'Segmento_CRM_Key',
  164.       Dim_Contrato.Segmento_Key length = 8  
  165.          format = 6.
  166.          informat = 6.
  167.          label = 'Segmento_Key',
  168.       Dim_Cliente.Ciclo_Key length = 8  
  169.          format = 4.
  170.          informat = 4.
  171.          label = 'Ciclo_Key',
  172.       Dim_Contrato.Estado_Plataforma_Key length = 8  
  173.          format = 4.
  174.          informat = 4.
  175.          label = 'Estado_Plataforma_Key',
  176.       Dim_Contrato.Antiguedad_Key length = 8  
  177.          format = 6.
  178.          informat = 6.
  179.          label = 'Antiguedad_Key',
  180.       Dim_Contrato.Equipo_Utilizado_Key length = 8  
  181.          format = 11.
  182.          informat = 11.
  183.          label = 'Equipo_Utilizado_Key',
  184.       Dim_Contrato.Plan_Key length = 8  
  185.          format = 11.
  186.          informat = 11.
  187.          label = 'Plan_Key',
  188.       Dim_Contrato.Cliente_Key length = 8  
  189.          format = 11.
  190.          informat = 11.
  191.          label = 'Cliente_Key',
  192.       Dim_Contrato.Estado_Legajo_Key length = 8  
  193.          format = 6.
  194.          informat = 6.
  195.          label = 'Estado_Legajo_Key',
  196.       Dim_Contrato.Fecha_Baja_Key length = 8  
  197.          format = 6.
  198.          informat = 6.
  199.          label = 'Fecha_Baja_Key',
  200.       Dim_Cliente.Fecha_Key length = 8  
  201.          format = 6.
  202.          informat = 6.
  203.          label = 'Fecha_Key',
  204.       Dim_Cliente.Estado_Morosidad_Key length = 8  
  205.          format = 4.
  206.          informat = 4.
  207.          label = 'Estado_Morosidad_Key',
  208.       Dim_Cliente.Perfil_Financiero_Key length = 8  
  209.          format = 6.
  210.          informat = 6.
  211.          label = 'Perfil_Financiero_Key',
  212.       Dim_Cliente.Estado_Cuenta_Key length = 8  
  213.          format = 6.
  214.          informat = 6.
  215.          label = 'Estado_Cuenta_Key',
  216.       Dim_Cliente.Tipo_Debito_Key length = 8  
  217.          format = 4.
  218.          informat = 4.
  219.          label = 'Tipo_Debito_Key',
  220.       Dim_Cliente.Entidad_Debito_Key length = 8  
  221.          format = 6.
  222.          informat = 6.
  223.          label = 'Entidad_Debito_Key',
  224.       Dim_Cliente.Cliente length = 8  
  225.          format = 11.
  226.          informat = 11.
  227.          label = 'Cliente',
  228.       Dim_Cliente.Tipo_Documento_Key length = 8  
  229.          format = 4.
  230.          informat = 4.
  231.          label = 'Tipo_Documento_Key',
  232.       Dim_Cliente.Numero_Documento length = 8  
  233.          format = 20.
  234.          informat = 20.
  235.          label = 'Numero_Documento',
  236.       Dim_Cliente.Numero_Documento_Editado length = 20  
  237.          format = $20.
  238.          informat = $20.
  239.          label = 'Numero_Documento_Editado',
  240.       Dim_Cliente.Documento_Key length = 8  
  241.          format = 20.
  242.          informat = 20.
  243.          label = 'Documento_Key',
  244.       Dim_Cliente.Localidad_Facturacion_Key length = 8  
  245.          format = 11.
  246.          informat = 11.
  247.          label = 'Localidad_Facturacion_Key',
  248.       Dim_Cliente.Cuenta length = 25  
  249.          format = $25.
  250.          informat = $25.
  251.          label = 'Cuenta',
  252.       Dim_Cliente.Cliente_Padre_Key length = 8  
  253.          format = 11.
  254.          informat = 11.
  255.          label = 'Cliente_Padre_Key',
  256.       Dim_Contrato.Fecha_Cambio_Titularidad_Key length = 8  
  257.          format = 6.
  258.          informat = 6.
  259.          label = 'Fecha_Cambio_Titularidad_Key',
  260.       Dim_Contrato.Fecha_Dormant_Key length = 8  
  261.          format = 6.
  262.          informat = 6.
  263.          label = 'Fecha_Dormant_Key',
  264.       Dim_Contrato.Fecha_Suspension_Key length = 8  
  265.          format = 6.
  266.          informat = 6.
  267.          label = 'Fecha_Suspension_Key',
  268.       Dim_Contrato.Estado_Contrato_Key length = 8  
  269.          format = 6.
  270.          informat = 6.
  271.          label = 'Estado_Contrato_Key',
  272.       Dim_Contrato.Estado_Dormant_Key length = 8  
  273.          format = 4.
  274.          informat = 4.
  275.          label = 'Estado_Dormant_Key',
  276.       Dim_Contrato.Tecnologia_Key length = 8  
  277.          format = 4.
  278.          informat = 4.
  279.          label = 'Tecnologia_Key',
  280.       Dim_Contrato.Equipo_Key length = 8  
  281.          format = 6.
  282.          informat = 6.
  283.          label = 'Equipo_Key',
  284.       Dim_Contrato.Blister_Key length = 8  
  285.          format = 4.
  286.          informat = 4.
  287.          label = 'Blister_Key',
  288.       Dim_Contrato.Punto_Venta_Key length = 8  
  289.          format = 11.
  290.          informat = 11.
  291.          label = 'Punto_Venta_Key',
  292.       Dim_Contrato.Representante_Key length = 8  
  293.          format = 11.
  294.          informat = 11.
  295.          label = 'Representante_Key',
  296.       Dim_Contrato.Promocion_Key length = 8  
  297.          format = 11.
  298.          informat = 11.
  299.          label = 'Promocion_Key',
  300.       Dim_Contrato.Condicion_Equipo_Key length = 8  
  301.          format = 6.
  302.          informat = 6.
  303.          label = 'Condicion_Equipo_Key',
  304.       Dim_Contrato.Origen_Equipo_Key length = 8  
  305.          format = 6.
  306.          informat = 6.
  307.          label = 'Origen_Equipo_Key',
  308.       Dim_Contrato.Canal_Venta_Key length = 8  
  309.          format = 6.
  310.          informat = 6.
  311.          label = 'Canal_Venta_Key',
  312.       Dim_Contrato.Motivo_Baja_Key length = 8  
  313.          format = 6.
  314.          informat = 6.
  315.          label = 'Motivo_Baja_Key',
  316.       Dim_Contrato.Fecha_Actualizacion_Key length = 8  
  317.          format = 11.
  318.          informat = 11.
  319.          label = 'Fecha_Actualizacion_Key',
  320.       Dim_Contrato.Plan_Inicial_Key length = 8  
  321.          format = 11.
  322.          informat = 11.
  323.          label = 'Plan_Inicial_Key',
  324.       Dim_Contrato.IMSI length = 15  
  325.          format = $15.
  326.          informat = $15.
  327.          label = 'IMSI',
  328.       Dim_Contrato.IMEI length = 14  
  329.          format = $14.
  330.          informat = $14.
  331.          label = 'IMEI',
  332.       Dim_Contrato.CNC_Numeracion_Key length = 8  
  333.          format = 11.
  334.          informat = 11.
  335.          label = 'CNC_Numeracion_Key',
  336.       Dim_Contrato.Plan_Anterior_Key length = 8  
  337.          format = 11.
  338.          informat = 11.
  339.          label = 'Plan_Anterior_Key',
  340.       Dim_Contrato.Tecnologia_Anterior_Key length = 8  
  341.          format = 4.
  342.          informat = 4.
  343.          label = 'Tecnologia_Anterior_Key',
  344.       Dim_Contrato.Estado_Contrato_Anterior_Key length = 8  
  345.          format = 6.
  346.          informat = 6.
  347.          label = 'Estado_Contrato_Anterior_Key',
  348.       Dim_Contrato.Estado_Dormant_Anterior_Key length = 8  
  349.          format = 4.
  350.          informat = 4.
  351.          label = 'Estado_Dormant_Anterior_Key',
  352.       Dim_Contrato.Estado_Plataforma_Anterior_Key length = 8  
  353.          format = 4.
  354.          informat = 4.
  355.          label = 'Estado_Plataforma_Anterior_Key',
  356.       Dim_Contrato.Segmento_CRM_Anterior_Key length = 8  
  357.          format = 6.
  358.          informat = 6.
  359.          label = 'Segmento_CRM_Anterior_Key',
  360.       Dim_Contrato.Estado_Parque_Anterior_Key length = 8  
  361.          format = 4.
  362.          informat = 4.
  363.          label = 'Estado_Parque_Anterior_Key',
  364.       Dim_Contrato.Cliente_Responsable_Key length = 8  
  365.          format = 11.
  366.          informat = 11.
  367.          label = 'Cliente_Responsable_Key',
  368.       Dim_Contrato.Fecha_Estado_Legajo_Key length = 8  
  369.          format = 6.
  370.          informat = 6.
  371.          label = 'Fecha_Estado_Legajo_Key'
  372.    from
  373.       OLAP.Dim_Contrato as Dim_Contrato inner join
  374.       OLAP.Dim_Cliente as Dim_Cliente
  375.          on
  376.          (
  377.             Dim_Contrato.Fecha_Key = Dim_Cliente.Fecha_Key
  378.             and Dim_Contrato.Cliente_Key = Dim_Cliente.Cliente_Key
  379.          )
  380.    where
  381.       (Dim_Contrato.Fecha_Baja_Key = -2000
  382.       or Dim_Contrato.Fecha_Baja_Key >= &fecha_ini.)
  383.       and Dim_Contrato.Linea <> 0
  384.    ;
  385. quit;
  386.  
  387. /*==========================================================================*
  388. *Modificacion llamado a crtlDepurador*
  389. *==========================================================================*/
  390.  
  391. proc sql;
  392. create table tmp_count as
  393.     select count(*) as cantidad
  394.     from work.WFM6STLY;
  395.     quit;
  396.  
  397. proc sql noprint;
  398.     select cantidad into :cantidad from tmp_count;
  399.     quit;
  400.  
  401. /*
  402. Path_Inc es una variable macro definida en appserver_autoexec.sas;
  403. /sasFiles/MA/bin/Parametros/sas
  404. */
  405.  
  406. %include "&Path_Inc./crtlDepurador.sas";
  407. %crtlDepurador(JOB_DIM_CONTRATO,&cantidad.)
  408.  
  409. %global etls_sql_pushDown;
  410. %let etls_sql_pushDown = &sys_sql_ip_all.;
  411.  
  412. /*==========================================================================*/
  413. %rcSet(&sqlrc.);
  414. /**  Step end Join **/
  415. /*==========================================================================*
  416.  * Step:            Extract                               A561KEHC.BW0001KJ *
  417.  * Transform:       Extract                                                 *
  418.  * Description:                                                             *
  419.  *                                                                          *
  420.  * Source Table:    Join - work.WFM6STLY                  A561KEHC.BX0001AY *
  421.  * Target Table:    STG_DIM_CONTRATO -                    A561KEHC.BH000015 *
  422.  *                   CM_STAGE.STG_DIM_CONTRATO                              *
  423.  *==========================================================================*/
  424.  
  425. %let transformID = %quote(A561KEHC.BW0001KJ);
  426. %let trans_rc = 0;
  427. %let etls_stepStartTime = %sysfunc(datetime(), datetime20.);
  428.  
  429. %let etls_recnt = -1;
  430. %let SYSLAST = %nrquote(work.WFM6STLY);
  431.  
  432. %global etls_sql_pushDown;
  433. %let etls_sql_pushDown = -1;
  434. option DBIDIRECTEXEC;
  435.  
  436. /*---- Map the columns  ----*/
  437. proc datasets lib = CM_STAGE nolist nowarn memtype = (data view);
  438.    delete STG_DIM_CONTRATO;
  439. quit;
  440.  
  441. %put %str(NOTE: Mapping columns ...);
  442.  
  443. proc sql;
  444.    create table CM_STAGE.STG_DIM_CONTRATO as
  445.       select
  446.          Contrato,
  447.          Contrato_Key,
  448.          Estado_Parque_Key,
  449.          Estado_Suspension_Key,
  450.          Fecha_Activacion_Key,
  451.          Linea,
  452.          Localidad_Anterior_Key,
  453.          Localidad_Key,
  454.          Segmento_CRM_Key,
  455.          Segmento_Key,
  456.          Ciclo_Key,
  457.          Estado_Plataforma_Key,
  458.          Antiguedad_Key,
  459.          Equipo_Utilizado_Key,
  460.          Plan_Key,
  461.          Cliente_Key,
  462.          Estado_Legajo_Key,
  463.          Fecha_Baja_Key
  464.    from &SYSLAST.
  465.    ;
  466. quit;
  467.  
  468. %let SYSLAST = CM_STAGE.STG_DIM_CONTRATO;
  469.  
  470. %global etls_sql_pushDown;
  471. %let etls_sql_pushDown = &sys_sql_ip_all.;
  472.  
  473. %rcSet(&sqlrc.);
  474.  
  475. /**  Step end Extract **/
  476.  
  477. /*---- Start of Post-Process Code  ----*/
  478.  
  479. %actualizarFechaOlap;
  480. /*---- End of Post-Process Code  ----*/
  481.  
  482. %rcSet(&syserr.);
  483. %rcSet(&sqlrc.);
  484.  
  485. %let etls_endTime = %sysfunc(datetime(),datetime.);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement