简体   繁体   English

SAS,地块标题

[英]SAS, plot title

How can I make the title to be "var1=e and var=b", suppose it is a repeat procedure (cannot hardcode). 假设标题是重复过程(无法硬编码),如何将标题设为“ var1 = e和var = b”。

  data test1;
    input y x var1$ var2$ key$;
    datalines;
    1  2 e b eb
    2  4 e b eb
    3  6 e b eb
    4  1 e b eb
    5  2 e b eb
    6  3 e b eb
    ;
    run;

proc sgplot data=test1 ;
series x=x y=y ;
title "I cannot make the title dynamic";
run;

The special title tokens #BYVAR<n> and #BYVAL<n> get replaced by the n-th by variable name and it's current grouping value. 特殊标题标记#BYVAR<n>#BYVAL<n>被变量名及其当前分组值替换为第n个。 This replacement occurs automatically as part of by group processing in procedures that produce output. 这种替换作为其一部分自动发生by在产生输出程序组的处理。

This example demonstrates how to turn off default by-lines and use the special tokens to produce the desired narrative in the output titles. 本示例演示了如何关闭默认行号并使用特殊标记在输出标题中产生所需的叙述。

data cars;
  Wheels = 4;
  set sashelp.cars;
run;

options nobyline;
title "#byvar1=#byval1 and #byvar2=#byval2";

proc sgplot data=cars;
  by wheels make;
  vbar model / response=horsepower nostatlabel;
run;

options byline;
title;

Read the values of VAR1 and VAR2 into a macro and then use that macro in the title. 将VAR1和VAR2的值读入宏,然后在标题中使用该宏。

proc sql noprint;
select var1, var2
   into :var1 trimmed, :var2 trimmed
   from test1(obs=1);
quit;

proc sgplot data=test1 ;
series x=x y=y ;
title "VAR1=&var1 and VAR2=&var2";
run;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM