我有一个奇怪的问题与PROC意义和使用StackODSOutput选项。考虑这个例子。SAS PROC与StackODSOutput的意义:一个名为“标签”的变量
我首先要建立一个分析数据集假人。
/* Step-1: Create a dummy dataset for analysis */
data ds1;
label x = 'Variable X';
label y = 'Variable Y';
do i = 1 to 100;
x = ranuni(1234);
y = ranuni(5678);
keep x y;
output;
end;
run;
然后,我用StackODSOutput选项运行PROC MEANS。这将创建一个名为“stats”的输出数据集。
/* Step-2: I run PROC means to capture the output in a dataset called stats */
proc means data=ds1 StackODSOutput mean;
var x y;
ods output summary=stats;
run;
这个“stats”数据集有一个名为“Label”的变量。我知道这个变量是存在的,因为我做了一个proc内容,并且在那里看到这个变量。
/* Step-3: Confirm visually that there is a variable called Label in stats dataset */
proc contents data=stats varnum; run;
但是,我似乎无法在任何地方引用这个名为“Label”的变量。例如,以下PROC SQL语句会生成一个错误。我可以在“统计”数据集中引用所有其他变量,而不会有任何问题。
/* Step-4: But, I cannot seem to reference the variable called "Label" in stats dataset! */
proc sql;
select Variable, Label from stats;
quit;
的错误如下:
43 proc sql;
44 select Variable, Label from stats;
ERROR: The following columns were not found in the contributing tables: Label.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
45 quit;
你知道,如果我做错了什么?我的SAS代码或SAS安装有问题吗?
MY SAS版本的SAS 9.3(9.03.01M2P08152012)。
谢谢。
Karthik。
根据Reeza的要求,这里是完整的日志输出。
1 The SAS System 15:52 Wednesday, November 9, 2016
1 %_eg_hidenotesandsource;
5 %_eg_hidenotesandsource;
20
21 /* Step-1: Create a dummy dataset for analysis */
22 data ds1;
23 label x = 'Variable X';
24 label y = 'Variable Y';
25 do i = 1 to 100;
26 x = ranuni(1234);
27 y = ranuni(5678);
28 keep x y;
29 output;
30 end;
31 run;
NOTE: The data set WORK.DS1 has 100 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
32
33 /* Step-2: I run PROC means to capture the output in a dataset called stats */
34 proc means data=ds1 StackODSOutput mean;
35 var x y;
36 ods output summary=stats;
37 run;
NOTE: The data set WORK.STATS has 2 observations and 3 variables.
NOTE: There were 100 observations read from the data set WORK.DS1.
NOTE: PROCEDURE MEANS used (Total process time):
real time 0.06 seconds
cpu time 0.03 seconds
38
39 /* Step-3: Confirm visually that there is a variable called Label in stats dataset */
40 proc contents data=stats varnum; run;
NOTE: PROCEDURE CONTENTS used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds
41
42 /* Step-4: But, I cannot seem to reference the variable called "Label" in stats dataset! */
43 proc sql;
44 select Variable, Label from stats;
ERROR: The following columns were not found in the contributing tables: Label.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
45 quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
2 The SAS System 15:52 Wednesday, November 9, 2016
46 /* What! */
47
48
49
50 %_eg_hidenotesandsource;
62
63
64 %_eg_hidenotesandsource;
67
代码工作正常,我。立即运行并再次检查,可能你在某处忘记了某处。你使用什么版本的SAS?我在9.4 TS1M3上。如果仍然无法运行,请在一次运行中从运行代码发布完整日志。 – Reeza
我的SAS版本是SAS 9.3(9.03.01M2P08152012)。另外,我添加了完整的SAS日志。 – Karthik
尝试设置'option validvarname = v7;'在开始时再试一次。如果不行,请发布proc内容的输出。我还建议提高技术支持。如果知道的问题,他们可以指出你在正确的方向。或者至少可以跟踪它。 – Reeza