有一SAS数据集sales.sas7bdat如下:
Obs EmpID Name Region Customer
1 1843 George Smith North Barco Corporation
2 1843 George Smith South Cost Cutter's
3 1843 George Smith North Minimart Inc.
4 1843 George Smith North Barco Corporation
5 1843 George Smith South Ely Corp.
6 0177 Glenda Johnson East Food Unlimited
7 0177 Glenda Johnson East Shop and Drop
8 1843 George Smith South Cost Cutter's
9 9888 Sharon Lu West Cost Cutter's
10 9888 Sharon Lu West Pet's are Us
我现在想以此数据集为基础,创建一个新的SAS数据集new_sales,new_sales只包含原数据集中的 Name Region变量,另外加上一个新的数值型变量Weight,weight的值与Region的值有如下关系:
Region weight
North 1.5
South 1.7
East 2.0
West 2.0
然后输出new_sales数据集。
以下是我编的程序:
data new_sales;
set learn.sales;
data sales_temprary;
set learn.sales;
select(Region);
when(North) weight=1.5;
when(South) weight=1.7;
when(East) weight=2.0;
when(West) weigh=2.0;
otherwise;
end;
proc print data=sales_temprary;
var region totalsales weight;
run;
结果输出来,weight的值都为1.5,不知道哪错了,望路过的大神指点迷津,谢谢啦!