Hi , I'm new to SAS DI. I've historical CSV files which I need to load into dataset. I currently load 1 by 1 which is painful and not pratical. I would like to use loop to load one time. sample file name is optionlog_20180101.csv. I've to load until Jun2018. When come to Feb , march, april etc I need to append data feb to optionlog_201802, march data to optionlog_201803. How I can create the table automatically base on the file csv. Really appreciate if someone can help me on this. Below is my script. libname IVRSTG '/u11/SAS/prod/Modelling/14_IVR'; data _null_; /*date_t = today();*/ date_t = '07Jan2018'd; daydt = intnx('day',date_t,-1); mth = intnx('month',date_t,-1); yyyymm=put(intnx("month",date_t,0,"end"),YYMMN6.); call symput ("yyyymm",yyyymm); call symput('filedt', put(daydt, yymmddn8.)); call symput('nrptdt', put(daydt, date9.)); call symput('tbldt', put(mth, yymmn6.)); call symput('dddt', daydt); run; %put &yyyymm; %put &filedt; %put &dddt; %put &tbldt; %put &nrptdt; %macro ivr; %if %sysfunc(fileexist("/u05/SAS/prod/bigdata/avaya/optionlog_&filedt..csv"))=0 %then %do; data _null_; file myfile; put "The optionlog_&filedt files was not received file from IVR."; put " "; put "Thanks!"; put " "; run; data work.optionlog_&filedt; LENGTH callid $50 optiondate $50 optionid $50 optioncode $50 accno $50 acctype $50 toaccno $50 toacctype $50 amount $50 chequeno $50 dbquery $50 hosttraceid $50 hostreqstatus $50 hoststatuscode $50 hoststatusdesc $250 /* indicator $50;*/ FORMAT callid $50. optiondate $50. optionid $50. optioncode $50. accno $50. acctype $50. toaccno $50. toacctype $50. amount $50. chequeno $50. dbquery $50. hosttraceid $50. hostreqstatus $50. hoststatuscode $50. hoststatusdesc $250. /* indicator $50. ;*/ format RPT_DATE date9.; RPT_DATE = "&nrptdt"d; stop;run; %end; %else %if %sysfunc(fileexist("/u05/SAS/prod/bigdata/avaya/optionlog_&filedt..csv")) %then %do; data work.optionlog_&filedt; infile "/u05/SAS/prod/bigdata/avaya/optionlog_&filedt..csv" lrecl = 256 delimiter = '|' dsd missover firstobs = 3; ; attrib callid length = $50; attrib optiondate length = $50; attrib optionid length = $50; attrib optioncode length = $50; attrib accno length = $50; attrib acctype length = $50; attrib toaccno length = $50; attrib toacctype length = $50; attrib amount length = $50; attrib chequeno length = $50; attrib dbquery length = $50; attrib hosttraceid length = $50; attrib hostreqstatus length = $50; attrib hoststatuscode length = $50; attrib hoststatusdesc length = $250; /* attrib indicator length = $50;*/ format RPT_DATE date9.; input callid optiondate optionid optioncode accno acctype toaccno toacctype amount chequeno dbquery hosttraceid hostreqstatus hoststatuscode hoststatusdesc ; RPT_DATE = "&nrptdt"d; run; %end; %mend ; %ivr; data IVRSTG.optionlog_&yyyymm; SET IVRSTG.optionlog_&yyyymm optionlog_&filedt; RUN;
... View more