BY 变量未显示在单变量频率中?
通常单变量频率不显示 BY 变量,而单变量基本测量则显示 BY 变量吗?
在下面的示例中,我加载了一些数据并希望按邮政编码显示汽油价格。 PROC FREQ
的输出在输出中显示 BY 变量 (zipcode
),与 UNIVARIATE BasicMeasures 一样。但单变量频率在输出中不显示 BY 变量。
我做错了什么吗?我什至使用 ODS PATH
语句将模板设置为默认值,以防模板被其他代码(或使用同一帐户的其他编码员)弄乱。
DATA prices;
INPUT zipcode price;
DATALINES;
90066 3.10
90066 3.17
90066 3.26
98101 2.99
98101 3.06
98101 3.16
;
run;
proc sort;
by zipcode;
run;
ods path sashelp.tmplmst(read) ;
ods pdf file = "gasprices.pdf";
PROC FREQ data = prices;
tables price;
by zipcode;
run;
ods select Frequencies;
PROC UNIVARIATE data = prices freq;
var price;
by zipcode;
run;
ods select BasicMeasures;
PROC UNIVARIATE data = prices;
var price;
by zipcode;
run;
ods pdf close;
Is it usual that the Univariate Frequencies does not display the BY-variable while Univariate BasicMeasures does show the BY-variable?
In the example below I load in some data and want to show gas prices by zipcode. The output for PROC FREQ
shows the BY-variable (zipcode
) in the output as does the UNIVARIATE BasicMeasures. But the UNIVARIATE Frequencies is not showing the BY-variable in the output.
Am I doing something wrong? I've even set the templates to default, with the ODS PATH
statement, in case the templates got messed up by other code (or other coders using same account).
DATA prices;
INPUT zipcode price;
DATALINES;
90066 3.10
90066 3.17
90066 3.26
98101 2.99
98101 3.06
98101 3.16
;
run;
proc sort;
by zipcode;
run;
ods path sashelp.tmplmst(read) ;
ods pdf file = "gasprices.pdf";
PROC FREQ data = prices;
tables price;
by zipcode;
run;
ods select Frequencies;
PROC UNIVARIATE data = prices freq;
var price;
by zipcode;
run;
ods select BasicMeasures;
PROC UNIVARIATE data = prices;
var price;
by zipcode;
run;
ods pdf close;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在 ODS SELECT 中指定多个对象,因此您可以将两个表从相同的 PROC FREQ 中拉出,如下所示:
我知道这并不能完全解决您的问题,但在我看来,BY 变量显示只是没有正确链接到 PROC UNIVARIATE 频率表(例如,尝试 ODS SELECT Moments - 工作正常)。可能值得向 SAS 报告。
You can specify more than one object in the ODS SELECT, so you could pull both tables out of the same PROC FREQ like this:
I know that doesn't exactly solve your problem, but it looks to me like the BY-variable display just isn't properly linked to the PROC UNIVARIATE frequency tables (e.g., try ODS SELECT Moments - works fine). Might be worth reporting to SAS.