One word: macros I don't know if your pdf code is part of the processing for each of the 11 files, but if so, you would be overwriting it each time. If it needs to run for each of the 11 files, then you can include it at the end of the macro. I've left it out. But for running the rest of code repeatedly for the 11 files, all you need to do is wrap it in a macro, and since your years are sequential, a simple macro %do loop is used to loop through each of the 11 files. %macro processyr;
%do yr=2006 %to 2016;
PROC IMPORT OUT= work.Ebsd
DATAFILE= "C:\Users\Xusheng\Desktop\OneDrive\MSCM5P04\A2\Original_Div\Div_&yr..csv"
DBMS=CSV REPLACE;*signify currency, year and month. if cite a word as the name, should be end up with '.', check ¤cy.,&year.,&i.;
GETNAMES=YES;
DATAROW=2;
RUN;
data work.EBSd;
set work.Ebsd;
rename at=TotalAsset;
rename bkvlps=BookValue;
rename capx=CapitalExpenditure;
rename dpc=Depreciation;
rename dt=TotalDebt;
rename dv=Dividend;
rename ebit=EBIT;
rename gp=GrossProfit;
rename ni=NetIncome;
rename seq=ShareholderEquity;
rename txt=IncomeTax;
rename wcapch=WorkingCapitalChange;
rename xint=InterestExpense;
rename xopr=OperatingExpense;
drop costat tie dp curcd tic datafmt popsrc consol indfmt fyear datadate gvkey;
run;
data work.EBSd;
set work.Ebsd;
if TotalAsset=. then delete;
if BookValue=. then BookValue=0;
if CapitalExpenditure=. then CapitalExpenditure=0;
if Depreciation=. then Depreciation=0;
if TotalDebt=. then TotalDebt=0;
if EBIT=. then EBIT=0;
if GrossProfit=. then GrossProfit=0;
if NetIncome=. then NetIncome=0;
if OperatingExpense=. then OperatingExpense=0;
if InterestExpense=. then InterestExpense=0;
if WorkingCapitalChange=. then WorkingCapitalChange=0;
if Dividend=0 then Dividend=0;
if Dividend>0 then Dividend=1;
if Dividend=. then Dividend=0;
run;
data work.EBSd;
set work.Ebsd;
CFO= EBIT + Depreciation - IncomeTax - WorkingCapitalChange;
FCF= CFO - CapitalExpenditure;
D_E= TotalDebt/ShareholderEquity;
ROE= NetIncome/ShareholderEquity;
drop TotalAsset CapitalExpenditure Depreciation TotalDebt EBIT GrossProfit NetIncome ShareholderEquity IncomeTax WorkingCapitalChange InterestExpense OperatingExpense CFO;
run;
Proc Export data=Work.Ebsd
Outfile= "C:\Users\Xusheng\Desktop\OneDrive\MSCM5P04\A2\Ready-For-Probit-Logit\Div_&yr..csv"
DBMS=csv replace;
Putname=yes;
run;
*Logit;
proc logistic data=work.Ebsd descending;
model Dividend = BookValue FCF D_E ROE/ ctable pprob=0.5;
output out = lout predicted=plogit;
run;
proc qlim data=work.Ebsd;
model Dividend = BookValue FCF D_E ROE/ discrete (dist=logit);
output out=logmargin marginal;
run;
proc means data=logmargin mean std;
var Meff_l_BookValue Meff_l_FCF Meff_l_D_E Meff_l_ROE;
run;
proc means data=lout;
var Dividend plogit;
run;
*Probit;
proc logistic data=work.Ebsd descending;
model Dividend = BookValue FCF D_E ROE/ link=probit ctable pprob=0.5;
output out=Pout predicted=pprobit;
run;
proc qlim data=work.Ebsd;
model Dividend = BookValue FCF D_E ROE/ discrete (dist=normal);
output out=probmargin marginal;
run;
proc means data=probmargin mean std;
var Meff_l_BookValue Meff_l_FCF Meff_l_D_E Meff_l_ROE;
run;
proc means data=Pout;
var Dividend pprobit;
run;
%end;
%mend;
%processyr;
... View more