Alert_Date is in the Database from which I intend to pull data with a where clause which is not static. Below is how I want - 1st Iteration- Account = X1 and Alert_Date >= 14MAR2021 and Alert_Date <= 13APR2021 2nd Iteration- Account = X2 and Alert_Date >= 20FEB2021 and Alert_Date <= 22MAR2021 and so on...all the values are in the data set I have using which I need to pull data from a DB. Below is the code I tried (includes multiple blocks) - *This code is for getting count of records, add index to each record. Data Temp3; Set mylib.Alerts_Distinct END=Last; By DECISION; Retain Counter; If (First.DECISION) then Do; Counter=1; End; Else Do; Counter+1; End; Run; *This code is for creating the macro variables for Account number, Start and End dates Options Symbolgen; DATA Temp4; SET Temp3 END=LAST; If LAST then Call SYMPUT('Count', PUT(Counter, 10.)); RUN; Data Temp5; Set Temp4; call symputx('ACCOUNT_NUMBER'||Left(put(_n_,5.)), CURRENT_ACCOUNT_NBR); call symputx('START_DATE'||Left(put(_n_,5.)), LOSS_START_DT); call symputx('END_DATE'||Left(put(_n_,5.)), LOSS_DT); run; The above code generates ACCOUNT_NUMBER1, ACCOUNT_NUMBER2 etc. holding values of Account numbers START_DATE1, START_DATE2 etc. holding the values of start dates of each records END_DATE1, END_DATE2 etc. holding the values of end dates of each records %macro sqlloop(start,end); Proc Sql; %DO i=&start. %TO &end.; create table Alerts as select * from Database where CONTACT_VALUE = '&ACCOUNT_NUMBER&i' and Alert_Date >= %Format('&START_DATE&i',Date9.) and Alert_Date <= %Format('&END_DATE&i',Date9.) ; %END; Quit; %Mend; %sqlloop(start=1, end=&Count.);
... View more