SAS:在Proc Freq命令中使用权重语句时出错

SAS:在Proc Freq命令中使用权重语句时出错,sas,sas-wps,Sas,Sas Wps,在SAS through WPS Workbench中,我尝试使用popn字段总体作为整数作为权重来获取数据的一些频率计数 proc freq data= working.PC_pops noprint; by District; weight popn / zeros; tables AreaType / out= _AreaType; run; 但是,当我运行上面的代码时,我得到以下指向我的权重语句的错误: ERROR: Found "/" when expec

在SAS through WPS Workbench中,我尝试使用popn字段总体作为整数作为权重来获取数据的一些频率计数

proc freq data= working.PC_pops noprint; 
    by District;
    weight popn / zeros; 
    tables AreaType / out= _AreaType;
run;
但是,当我运行上面的代码时,我得到以下指向我的权重语句的错误:

ERROR: Found "/" when expecting ;
ERROR: Statement "/" is not valid
我已经在线检查了语法,为了在权重中包含零计数,它明确表示在权重语句中使用/zeros选项,但是SAS WPS出错了?我做错了什么


更新:我现在发现WPS工作台不支持zeros选项。有解决方法吗?

如果您没有使用PROC FREQ统计测试的任何高级元素,您最好使用PROC TABLATE。这将允许您使用几种不同的方法精确定义输出中所需的级别,即使它们具有零元素。这是一个有点老套的解决方案,但至少在SAS 9.4中是有效的:

data class;
  set sashelp.class;
  weight=1;
  if age=15 then weight=0;
run;

proc freq data=class;
  weight weight/zeros;
  tables age;
run;


proc tabulate data=class;
  class age;
  var weight;
  weight weight; *note this is WEIGHT, but does not act like weight in PROC FREQ, so we have to hack it a bit by using it as an analysis variable which is annoying;
  tables age,sumwgt='Count'*weight=' '*f=2.0;
run;
两者给出相同的结果。您还可以使用CLASSDATA集,它的黑客性稍低,但我不确定它在非SAS中的支持程度:

proc sort data=class out=class_classdata(keep=age) nodupkey;
  by age;
run;

proc tabulate data=class classdata=class_classdata;
  class age;
  freq weight;  *note this is FREQ not WEIGHT;
  tables age,n*f=2.0/misstext='0';
run;

不幸的是,硬编码。WPS就像使用一个有20年历史的SAS版本。您的最佳示例是在proc freq语句中使用weight\zero,这是我最初的问题,因为它不受支持?我想您误解了我的示例。我写了一个表格式的解决方案,它模仿了FREQ解决方案,并通过将两者相邻显示来展示这一点。在基本SAS中,它们给出相同的结果,因此WPS可能会支持表格方法。