变量值作为 sas ods 中的标题

Variable value as title in sas ods

我有一个数据集,其中一个变量的值如下 诊断 780.7 804.7 101.7 通过 ods 和 proc 报告,我希望这个值作为 sheet 的标题,如下所示:

诊断 * 780.7 * 804.7 * 101.7

谁能告诉我如何通过 ods 在 excel sheet 中将变量值作为标题抛出。

这取决于您的数据的外观。让我们将您的特殊值称为 value 并假设它是字符格式。该特殊值位于变量列中,我们称它为 Var1。 你把 if 语句放在下面,

data _null_;
set yourdata;
if Var1 = "value" then   /* if "Var1" is equal to "value" then */ 
call symput ('value1',Var1);  /* create a Macro variable with call symput*/ 
run;                         /* Now you can use this &value1 anywhere in your code  */

ods listing close;

  ods tagsets.excelxp file="&path\yourfile.xls" style=statistical
  options(sheet_name='&value1.*'); /* If you want to add a character into the sheet name, 
                                    then you can write &value.* as there is a dot between them */
  ;

  proc print data=yourdata; run;

  ods tagsets.excelxp close;

 ods listing;