如何打印SAS报告webout文件中的选中和未选中复选框

如何打印SAS报告webout文件中的选中和未选中复选框,sas,sas-macro,Sas,Sas Macro,我有一个名称建议表,其中有一个列名称值\u cd。 此列包含一些复选框的值,这些值将在我的webout报告中被选中。我想勾选所有相关值在此列中的复选框 table:Proposal value_cd New_par Rev_par 这是我的密码 data _null_; put numberOfObservationes=; set work.Proposal nobs=numberOfObservationes; file _webout; if value

我有一个名称建议表,其中有一个列名称值\u cd。 此列包含一些复选框的值,这些值将在我的webout报告中被选中。我想勾选所有相关值在此列中的复选框

table:Proposal 
  value_cd

   New_par
   Rev_par
这是我的密码

data _null_;
 put numberOfObservationes=;
 set work.Proposal nobs=numberOfObservationes;
 file _webout;
    if value_cd eq "New_par" then put '<input type=checkbox disabled checked /> <label>New Parameter</label> <br /> <hr /> ';
          else put '<input type=checkbox disabled /> <label>New Parameter</label> <br /> <hr /> ';
    if value_cd eq "Rev_par" then put '<input type=checkbox disabled checked /> <label>Revised Parameter</label> <br /> <hr /> ';
          else put '<input type=checkbox disabled /> <label>Revised Parameter</label> <br /> <hr /> ';
    if value_cd eq "New_pro" then put '<input type=checkbox disabled checked /> <label>New Process</label> <br /> <hr /> ';
          else put '<input type=checkbox disabled /> <label>New Process</label> <br /> <hr /> ';
run;
上面的代码是下面的打印输出

  checkbox checked New Parameter  *if-statement;
  checkbox Revised Parameter      *else-statement;
  checkbox New Process            *else-statement;
  checkbox New Parameter          *else-statement;
  checkbox checked Revised Parameter   *if-statement;
  checkbox New Process            *else-statement;

按行显示发生了什么,6个复选框:

row-1: logic-1-output logic-2-output logic-3-output
row-2: logic-1-output logic-2-output logic-3-output
row-1: track-logic-1-for-true track-logic-2-for-true track-logic-3-for-true
row-2: track-logic-1-for-true track-logic-2-for-true track-logic-3-for-true
last-row: output-based-on-tracked-logics
需要什么,3个复选框:

row-1: logic-1-output logic-2-output logic-3-output
row-2: logic-1-output logic-2-output logic-3-output
row-1: track-logic-1-for-true track-logic-2-for-true track-logic-3-for-true
row-2: track-logic-1-for-true track-logic-2-for-true track-logic-3-for-true
last-row: output-based-on-tracked-logics
这里有一种方法

跟踪所有行上出现的值\u cd状态,然后执行输出

data _null_;
 put numberOfObservationes=;
 set work.Proposal nobs=numberOfObservationes end=last_row;

 array boxes[3] _temporary_; * 1st slot is for New_par, 2nd for Rev_par, etc..;

 * track for true using OR;
 boxes[1] = boxes[1] or (value_cd eq "New_par");
 boxes[2] = boxes[2] or (value_cd eq "Rev_par");
 boxes[3] = boxes[3] or (value_cd eq "New_pro");

 if last_row then do;
    if boxes[1]
      then checked_attribute='checked'; 
      else checked_attribute='';

    put '<input type=checkbox disabled ' checked_attribute '/> <label>New Parameter</label> <br /> <hr /> ';

    if boxes[2]
      then checked_attribute='checked'; 
      else checked_attribute='';

    put '<input type=checkbox disabled ' checked_attribute '/> <label>Revised Parameter</label> <br /> <hr /> ';

    if boxes[3]
      then checked_attribute='checked'; 
      else checked_attribute='';

    put '<input type=checkbox disabled ' checked_attribute '/> <label>New Process</label> <br /> <hr /> ';
  end;
run;
数据\u空\u;
将观察次数=;
设置工作。提案nobs=观察次数结束=最后一行;
阵列框[3]u临时_;*第一个插槽用于新的标准杆,第二个插槽用于修订标准杆等。。;
*跟踪真实使用或记录;
方框[1]=方框[1]或(价值等于“新面值”);
方框[2]=方框[2]或(价值等于“修订价格”);
框[3]=框[3]或(值_cd eq“New_pro”);
如果是最后一行,那么做;
如果框[1]
然后选中_attribute='checked';
else checked_属性=“”;
放入“新参数

”; 如果框[2] 然后选中_attribute='checked'; else checked_属性=“”; 放入“修改后的参数

”; 如果框[3] 然后选中_attribute='checked'; else checked_属性=“”; 放置“新流程

”; 结束; 跑
注意:上面的代码实质上是将value_cd数据从一列旋转到一行

在数据步骤中,隐式循环顶部的变量值通常重置为缺失(在这种情况下,从第1行转到第2行)。为了逐行跟踪条件,隐式循环不应重置变量

有几种方法可以避免重置:

  • 使用
    RETAIN
    变量
  • 使用
    \u临时数组
  • 绝不允许隐式循环出现一次以上:
    • 在显式编码的
      do while
      do till
      循环中使用
      SET
  • 将您的所有状态信息放在一行中(即数据透视)

你好。可能您需要使用开关盒功能?