跨多个变量的值的频率

跨多个变量的值的频率

本文介绍了跨多个变量的值的频率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个患者信息数据集,我想在其中计算有多少患者(观察)具有给定的诊断代码.我有 9 个可能的变量,在 diag1、diag2...diag9 中.代码为 V271.我无法弄清楚如何使用WHERE"子句或 proc freq 来做到这一点.

I have a data set of patient information where I want to count how many patients (observations) have a given diagnostic code. I have 9 possible variables where it can be, in diag1, diag2... diag9. The code is V271. I cannot figure out how to do this with the "WHERE" clause or proc freq.

任何帮助将不胜感激!

推荐答案

您的基本策略是创建一个非患者级别的数据集,但一个观察结果是一个患者诊断代码(因此每个患者最多 9 个观察结果).像这样的:

Your basic strategy to this is to create a dataset that is not patient level, but one observation is one patient-diagnostic code (so up to 9 observations per patient). Something like this:

data want;
  set have;
  array diag[9];
  do _i = 1 to dim(diag);
    if not missing(diag[_i]) then do;
      diagnosis_Code = diag[_i];
      output;
    end;
  end;
  keep diagnosis_code patient_id [other variables you might want];
run;

然后您可以在结果数据集上运行 proc freq.您还可以将条件从不丢失更改为 if diag[_i] = 'V271' then do; 以仅获取数据中的 V271.

You could then run a proc freq on the resulting dataset. You could also change the criteria from not missing to if diag[_i] = 'V271' then do; to get only V271s in the data.

这篇关于跨多个变量的值的频率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 11:47