2

我有这个数据集:

data flu;
  input FluShotStatus age HealthAwareIndex gender;

  datalines;

  0    59    52    0
  0    61    55    1
  1    82    51    0
  0    51    70    0
  0    53    70    0
  0    62    49    1
  1    51    69    1
  0    70    54    1
  0    71    65    1
  0    55    58    1
  1    58    48    0
  0    53    58    1
  0    72    65    0
  1    56    68    0
  0    56    83    0
  0    81    68    0
  1    62    44    0
  ;
run;

我正在尝试从此数据集中生成多个不同的图。

首先,我想使用 ODS 为变量 Health Awareness Index 生成一个 QQ 图。我已经使用了这段代码,它可以满足我的需求,但我觉得它可能会更好:

ods graphics on;
  proc univariate data=Measures;
      var Length Width;
      qqplot;
title ‘QQ Plot for Health Awareness Index’;
ods graphics off;
run;

接下来,我想使用 ODS 生成散点图,仅用于男性受试者的健康意识指数和年龄。我试过使用:

ods graphics on;
proc sgscatter data=flu;
plot HealthAwareIndex*weight
run;
ods graphics off;

我想知道该怎么做,但我不知道你将如何在一页上生成单独的直方图?非常适合 50 至 70 岁的男性。任何提示或帮助将不胜感激。

4

1 回答 1

0

这些可以使用sgplotand创建sgpanel

1)散点图(假设gender男性为1):

ods graphics on;
proc sgplot data = flu(where = (gender= 1));
  scatter x = age y=HealthAwareIndex;
run;
ods graphics off;

2)QQ情节

您可以使用 导出 QQ 图的值proc rank,然后使用 scater in 绘制它们sgplot。要为您的 QQ 图获取一条线,您可以使用proc sql获取比例和位置参数的值,然后在lineparm语句中使用它们:

proc rank data=flu normal=blom out=haiQuant;
  var healthawareindex;
  ranks hai_Quant;
run;

** add line to plot;
proc sql;
  select mean(HealthAwareIndex), std(HealthAwareIndex)
  into :location, :scale
  from flu;
quit;

proc sgplot data=haiQuant;
  scatter x=hai_Quant y=HealthAwareIndex;
  xaxis label="Normal Quantiles";
  lineparm x = 0 y = &location slope = &scale;
run;

3) 直方图

要将多个图放在一页上,您可以使用sgpanelsgplot. 使用该panelby语句更改面板之间的图,这是一个使用示例FluShotStatus

proc sort data = flu;
  by gender;
run;

proc sgpanel data = flu;
  panelby fss;
  vbox  HealthAwareIndex / category = gender;
run;

这些都需要用标题、适当的颜色等来美化,但应该是一个很好的轮廓。

于 2017-02-20T17:45:24.900 回答