简体   繁体   English

SAS:如何重命名 sgplot 散点图上的轴标签名称

[英]SAS: How do I rename an axis label name on sgplot scatter plot

I'm an Animal science student from Slovenia and I'm just finishing my master's thesis.我是来自斯洛文尼亚的动物科学专业的学生,​​我刚刚完成我的硕士论文。 For the finishing touches i need to make a bunch of scatter plots of different traits.最后,我需要制作一堆不同特征的散点图。 All my data values (breeding values of different traits) are in code, for example m_pv10 (omišičenost = muscularity), m_pv31 (age of first calving),... To make the scatter plots easier to read i'd like to rename the x and y-axis labels from m_pv31 to "Age of first calving".我所有的数据值(不同性状的育种值)都在代码中,例如 m_pv10(omišičenost = muscularity)、m_pv31(第一次产犊的年龄),...为了使散点图更易于阅读,我想重命名x 和 y 轴标签从 m_pv31 到“第一次产犊年龄”。 I have tried renaming the values in a data step to bypass this problem but some names of the traits include spaces "age of first calving" and no nregular letters as "š" and "č" so the data step won't work.我曾尝试重命名数据步骤中的值来绕过这个问题,但特征的一些名称包括空格“首次产犊年龄”并且没有像“š”和“č”这样的不规则字母,因此数据步骤将不起作用。

data datam_copy;
   set datam_copy;
   rename m_pv10=Omišičenost;
          m_pv31=Starost ob prvi telitvi;
          m_pv12=Vime;run;

Is there a way to rename the axis labels directly in the sgplot code?有没有办法直接在 sgplot 代码中重命名轴标签? I would be very tratefull for any suggestions.我会非常感谢任何建议。

Urban城市的

You can use the variable label, if that is the level you're working at.您可以使用变量标签,如果这是您工作的级别。 Here's an example.这是一个例子。

data have;
  set sashelp.class;
  label age="Age of student"
        height="Height of student"
        weight="Weight of student"
        ;
run;

proc sgplot data=have;
  vline age/response=height;
  vline age/response=weight y2axis;
run;
  

You can rename the variable also of course, but this is really the job of the variable label.当然,您也可以重命名变量,但这实际上是变量标签的工作。 You can also use the label statement directly in sgplot .您也可以直接在sgplot使用label语句。

proc sgplot data=sashelp.class;
  vline age/response=height;
  vline age/response=weight y2axis;
  label age="Age of student"
        height="Height of student"
        weight="Weight of student"
        ;
run;
  

You can have spaces in the name but generally not a great idea though.您可以在名称中包含空格,但通常不是一个好主意。 Not sure how the accents will work though.不确定口音将如何工作。

options validvarname = any;

data datam_copy;
   set datam_copy;
   rename m_pv10= 'Omišičenost'n;
          m_pv31= 'Starost ob prvi telitvi'n;
          m_pv12= 'Vime'n;
run;

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

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