You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Proc Univariate中设置X轴端点遇异常,如何移除X轴的110刻度?

SAS直方图X轴刻度异常问题解决

问题场景

我用以下SAS代码生成模拟数据,并基于分组绘制直方图:

data mydata;
    call streaminit(1234);
    do binary = 0 to 1;
        do i = 1 to 1000;
            var = rand('integer', 0, 150);
            output;
        end;
    end;
run;

proc univariate data=mydata noprint;
where var le 100;
class binary;
histogram var/overlay endpoints=0 to 100;
run;

执行后结果不符合预期:X轴显示了110的刻度,且100对应的条形位于该刻度右侧。我需要调整X轴格式,使其不显示110刻度。

补充说明:我曾尝试修改数据限制值,当限制为80或90时,X轴会在对应值处正常截断,但仅当限制为100时,X轴会自动延伸出110刻度。


尝试与解决方法

尝试方法1:改用Proc SGPlot指定X轴刻度

我尝试改用proc sgplot并直接定义X轴的刻度范围,代码如下:

proc sgplot data=mydata;
histogram var/group=binary;
xaxis values=(0 to 100 by 10);
run;

有效解决方法:Proc Univariate中替换为midpoints参数

经Richard建议,在proc univariate的直方图语句中用midpoints替代endpoints,该方法成功解决了X轴延伸的问题。


内容的提问来源于stack exchange,提问作者user10969476

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 14:45:04