ntsean 发表于 2013-4-16 09:57
没有数据不好调试,不过大概就是这个样子,先用sql存到一个macro variable,然后替换到univariate option里 ...
这台电脑打不了中文, 只能用百度太麻烦了. 谢谢你的帮助, 我还有一些问题. 已经增加了悬赏额.
I have uploaded the data files into the main post. Please check them out first.
My expected outcome is the file entitled "comboNeg_0," but my new codes were unable to reach the goal. If you could help me combine the two datasets into one "comboNeg_0," then my following codes should work well for hypothesis tests. Basically, every observation or cell in variable Consecutive1, Consecutive2, Consecutive3, and Consecutive4 has to match with every cell in AR1, AR2, AR3, and AR4. Then, I can calculate the difference between Consecutive1 and AR1, and so on. Every value in AR1, AR2, AR3, AR4 is the same as the value of annual_return in the dataset entitled "summary."
Please let me know if you could help me revise the following codes. I also added your codes below which worked very well. However, I have not learned proc sql procedure before, so I preferred to use my way to solve the problem. Thanks for your help again.
/* input data */
PROC IMPORT OUT= SASUSER.inputNeg0
DATAFILE= "H:\My Documents\inputNeg0.xlsx"
DBMS=EXCEL REPLACE;
RANGE="Sheet1$";
GETNAMES=YES;
MIXED=NO;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;
RUN;
/* summary of returns */
PROC IMPORT OUT= SASUSER.Summary
DATAFILE= "H:\My Documents\summary.xlsx"
DBMS=EXCEL REPLACE;
RANGE="Sheet1$";
GETNAMES=YES;
MIXED=NO;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;
RUN;
dm 'out;clear;log;clear;'; /* clear log window */
ods html close; /* close previous results */
ods html; /* generate new results */
options linesize = 100 lrecl = 1000;
/* inputNeg_0 analysis */
data inputNeg_0;
set SASUSER.inputNeg0;
run;
proc means data = inputNeg_0 n mean stddev clm alpha = 0.05 NMISS;
var Consecutive1 Consecutive2 Consecutive3;
run;
/* summary for annual return */
data summary_return;
set SASUSER.summary;
keep annual_return;
run;
proc print data = summary_return;
run;
data test_neg0;
merge inputNeg_0 summary_return;
run;
proc print data = test_neg0;
run;
data test_neg0_array;
set test_neg0;
array Consecutive(3) Consecutive1-Consecutive3;
do i = 1 to 3;
If Consecutive(i) =. then Consecutive(i) = -1;
If Consecutive(i) > -1 then do;
Consecutive(i) = Consecutive(i) - annual_return;
end;
end;
drop i;
run;
proc print data = test_neg0_array;
run;
proc univariate data = test_neg0_array mu0=0 0 0 alpha = 0.05;
var Consecutive1 Consecutive2 Consecutive3;
run;
/* p-values are compared with (alpha/n) */
proc sql noprint;
select annual_return into: return separated by " "
from SASUSER.summary;
quit;
proc univariate plot data = test_neg0 mu0= &return;
var Consecutive1 Consecutive2 Consecutive3;
run;
proc corr data = inputNeg_0;
run;