【发布时间】:2016-11-09 19:15:12
【问题描述】:
我对 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;
这个“统计”数据集有一个名为“标签”的变量。我知道变量存在,因为我做了一个 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 安装有问题吗?
我的 SAS 版本是 SAS 9.3 (9.03.01M2P08152012)。
谢谢。
卡提克。
根据 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 上。如果仍然无法正常工作,请一次性发布运行代码的完整日志。
-
我的 SAS 版本是 SAS 9.3 (9.03.01M2P08152012)。另外,我添加了完整的 SAS 日志。
-
尝试设置'option validvarname=v7;'在开始时再试一次。如果不行,请发布 proc 内容的输出。我还建议通过技术支持来提高这一点。如果已知问题,他们可以为您指明正确的方向。或者至少可以跟踪它。
-
找到一个格式正确的问题和一个有趣的问题真是令人耳目一新。点赞!
-
这里是关于这个问题的讨论。 SAS 技术支持已注意到这一点。 communities.sas.com/t5/SAS-Enterprise-Guide/…
标签: sas