【发布时间】:2018-01-24 03:06:11
【问题描述】:
我需要创建一个变量,它结合了三个变量 age 、 sexe 和 agios。它们都位于 sas 表中,并且都是数字的。
第一步,我将它们转换为分类变量,然后我建议使用 compress 函数来创建这个新变量:
data new;
set new;
attrib sexe format=$15.;
if sexe=1 then sexe="HOMME";
else if sexe=0 then sexe="FEMME";
attrib agios format=$15.;
if agios=0 then agios="NON_AGIOS";
else AGIOS="AGIOS";
attrib age format=$15.;
if (age<=0) and (age=>25) then age="a25";
if (age<=26) and (age=>40) then age="a40";
if (age<=41) and (age=>65) then age="a60";
if (age=>65) then age="a65";
new_variable=compress(agios||sexe||age);
run;
But I have an warnings repeted to all the concerned variables:
警告:变量 agios 已被定义为数字。
并且表中的变量没有任何转换。此外,相关变量 age 、 sexe 和 agios 的值从表中消失。它开始是空的。
请问我该如何纠正这个问题? 或者有没有其他建议不使用 ifelse 来创建新变量?
谢谢
【问题讨论】:
标签: sas