Hi, I am fairly new to SAS. This is the piece of sas code that I am running. I am trying to get the same date previous month based on the value fetched from the database. ======================================== %macro load_table_dly; proc sql noprint; %put >>>>> CONNECTING TO DB <<<<<; connect to &prod_mba_driver(&prod_mba_db_connection_passthru user=&userid password=&passwd); %put >>>>> EXTRACTING BUSINESS DATE FROM THE DB <<<<<; select bus_dt into :v_bus_dt from connection to &prod_mba_driver (select bus_dt from (select ''''||coalesce(max(mech.bus_dt),cast(&db2_day0. as date))||'''' as bus_dt from yyyyyyy as mech where 1=1 and cast(mech.cad_run_dtm as date) = &db2_day0. ) as mx_dt ); %put >>>>> DISCONNECTING FROM PROD_MBA <<<<<; disconnect from &prod_mba_driver; quit; %put &=v_bus_dt; /*display the fetched date */ data dates; datelastmonth = intnx('month',v_bus_dt,-1,'S'); /* Get the previous month, same date */ run; %mend load_table_dly; %load_table_dly; ================================================== From the log file: V_BUS_DT='2023-06-12' NOTE: Variable v_bus_dt is uninitialized. Help appreciated
... View more