gpt4 book ai didi

sas - 替换 SAS 数据集中的值

转载 作者:行者123 更新时间:2023-12-02 00:36:11 24 4
gpt4 key购买 nike

我想要一个代码来将列中的数字替换为字符。

例如:0-“否 1-”是。

我尝试使用 if/else 但它不起作用!!!

Data Assign2.Grocery_coup_two;                                                                                                          
Set Assign2.Grocery_coupons;
If Heath_food_Store = 0
then Health_food_Store = "No";
Else Health_food_Store = "Yes";
Run;





Health_Food_Store
0
0
0
0
1
0
1
0
0
0
1
0
1
0
0
1

最佳答案

您的解决方案不起作用,因为您正试图将数字变量转换为字符串变量。解决此问题的一种方法是将数字变量重命名为 _old,然后运行 ​​if-else 语句:

Data Assign2.Grocery_coup_two;                                                                                                          
Set Assign2.Grocery_coupons (rename = (Health_food_Store = Health_food_Store_old));
If Heath_food_Store_old = 0
then Health_food_Store = "No";
Else Health_food_Store = "Yes";
DROP Health_food_Store_old;
Run;

关于sas - 替换 SAS 数据集中的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49472191/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com