我正在尝试重建一个看起来像这样的图表:这是一个堆叠的条形图,有许多类型的访问,带有附加数据表中显示的值和两种类型的目标线。

我的数据如下所示(我不确定如何创建示例代码):

我对数据进行了转换,所以它很长:

我的方法是基于this的。
在本例中,如果我使用线程中的示例数据运行第一个注释部分(anno_values),则一切运行正常。但是,使用类似的设置但要考虑更多的组(Visit1、Visit2等)我一直收到这个错误消息:
NOTE: ERROR DETECTED IN ANNOTATE= DATASET WORK.ANNO_VALUES.
MINIMUM VARIABLES NOT MET - AMBIGUITY PREVENTS SELECTION
NOTE: ERROR LIMIT REACHED IN ANNOTATE PROCESS. PROCESSING IS TERMINATED.
NOTE: PROCESSING TERMINATED BY INDIVIDUAL ERROR COUNT.
NOTE: 1 TOTAL ERRORS.
data anno_values; set long2;
format xc monyy.; informat month monyy.;
xsys='2'; ysys='3'; hsys='3'; when='a';
function='label'; position='5';
xc=month;
if type='Total' then do;
y=15;
text=trim(left(value));
output;
end;
if type='Visit1' then do;
y=7;
text=trim(left(value));
output;
end;
if type='Visit2' then do;
y=0;
text=trim(left(value));
output;
end;
if type='Visit3' then do;
y=-7;
text=trim(left(value));
output;
end;
run;
proc gchart data=long2 anno=anno_values;
vbar month / type=sum sumvar=value discrete
subgroup=type nolegend
raxis=axis1 maxis=axis2
coutline=gray77;
run; quit;我不确定是否是这几个月导致了这个问题,但我不能比第一步走得更远。
发布于 2018-12-04 15:41:43
随SAS/Graph一起安装的宏将帮助您构建正确的注释数据集。宏的名字是dclanno,意思是声明变量。
将以下行添加到您的代码中:
%annomac /* compiles the SAS/Graph annotation macros */
data myAnno;
/* The dclanno macro, part of the annomac package does code generation
* for defining the annotation variables in the PDV
*/
%dclanno;dclanno是安装在SASFoundation\9.4CORE\SASM宏中的annomac包的一部分。
以下是指向A stacked vbar chart annotated to display counts of another subgroup的另一个示例的链接
https://stackoverflow.com/questions/53601789
复制相似问题