我正在使用 SAS 大学版。我需要根据现有的亚种族创建一个新的种族变量。有没有办法选择“全部白”而不是指定“白俄罗斯”或“白欧洲”并创建新变量。
这是我的代码。
data agg1;
set agg;
if ethnicity = 'WHITE' then ethnicity1= 'white' ;
if ethnicity = 'WHITE-RUSSIAN' then ethnicity1= 'white' ;
if ethnicity = 'WHITE-EUROPEAN' then ethnicity1= 'white';
.
.
run ;
假设ethnicity
变量的值始终为 format '<main>-<sub>'
,您可以将其减少为一行零if
语句:
data agg1;
set add;
ethnicity1=scan(ethnicity,1,'-');
run;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句