BY 变量未显示在单变量频率中?

发布于 2024-09-07 12:13:17 字数 786 浏览 2 评论 0原文

通常单变量频率不显示 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

似最初 2024-09-14 12:13:17

您可以在 ODS SELECT 中指定多个对象,因此您可以将两个表从相同的 PROC FREQ 中拉出,如下所示:

ods pdf file = "gasprices.pdf"; 
ods select BasicMeasures Frequencies; 
PROC UNIVARIATE data = prices freq; 
  var price; 
  by zipcode; 
run; 
ods pdf close; 

我知道这并不能完全解决您的问题,但在我看来,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:

ods pdf file = "gasprices.pdf"; 
ods select BasicMeasures Frequencies; 
PROC UNIVARIATE data = prices freq; 
  var price; 
  by zipcode; 
run; 
ods pdf close; 

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文