如何更改sas数据集中列的值
我的数据集是这样的 我想将所有“未来6个月内”更改为“<6个月” 同样,所有的“6个月到1年”到“6个月到12个月”如何更改sas数据集中列的值,sas,Sas,我的数据集是这样的 我想将所有“未来6个月内”更改为“
我们怎么能做到呢 您可以尝试使用以下示例中的tranwrd函数(请注意,它不是以最有效的方式编写的):
数据输出1;
设置src;
text=tranwrd(text,“在未来6个月内”,“小于6个月”);
text=tranwrd(text,“6个月至1年”、“6至12个月”);
跑
替代解决方案可能涉及使用以下格式:
proc format;
value $sample_format
"Within the next 6 months"="< 6 Months"
"Between 6 months and a year"="6 to 12 months"
;
run;
data out2;
set src;
text = put(text, $sample_format.);
run;
proc格式;
值$sample\u格式
“在未来6个月内”=“<6个月”
“6个月到一年之间”=“6到12个月”
;
跑
数据输出2;
设置src;
text=put(text$sample_格式);
跑
您可以执行以下操作,只需加载您需要更改的等待时间的任何其他值即可:
data input ;
set input ;
select (wait_time) ;
when ('Within the next 6 months') wait_time='<6 Months' ;
when ('Between 6 months and a year') wait_time='6 to 12 Months' ;
otherwise ;
end ;
run ;
数据输入;
设置输入;
选择(等待时间);
什么时候(在未来6个月内)等待
data input ;
set input ;
select (wait_time) ;
when ('Within the next 6 months') wait_time='<6 Months' ;
when ('Between 6 months and a year') wait_time='6 to 12 Months' ;
otherwise ;
end ;
run ;