楼主: zhangxi689
1581 1

[问答] SAS 求助! [推广有奖]

  • 0关注
  • 0粉丝

大专生

3%

还不是VIP/贵宾

-

威望
0
论坛币
22125 个
通用积分
0.1500
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
377 点
帖子
3
精华
0
在线时间
72 小时
注册时间
2013-9-3
最后登录
2023-2-6

300论坛币

有一道SAS作业题,怎麼编都做不出最后一张表的结果,求大神帮忙!


Identifying Extreme Valuesin Each Group of Data

The data set orion.customer_dim contains informationabout Orion Star customers.

Partial orion.customer_dim(77 Total Observations, 11 Total Variables)

                                                                                    Customer_

   Customer_ID    Customer_Name          Customer_Type                              BirthDate

             4    James Kvarniq          Orion Club members low activity            27JUN1978

             5    Sandrina Stephano      Orion Club Gold members mediumactivity    09JUL1983

             9    Cornelia Krahl         Orion Club Gold members mediumactivity    27FEB1978

            10    Karen Ballinger        Orion Club members high activity         18OCT1988

            11    Elke Wallstab          Orion Club members high activity         16AUG1978


Use First./Last.processing to create the report below. Show data on the oldest and youngestcustomers for each Customer_Type.

·   The variable o_ID is the Customer_ID value of the oldest customer and y_ID is the Customer_IDvalue of the youngest customer for each group.

·   Create a variable named agerange to indicate the spread betweenthese oldest and youngest customers.

·   Use Customer_BirthDate, rather than Customer_Age, for all age determinations because this is moreaccurate.

Partial PROC PRINT Output (7 Total Observations)

Oldest and Youngest Customers of eachCustomer Type

Customer_Type                                 oldest     youngest     o_ID    y_ID    agerange

Internet/CatalogCustomers                 08JUL1938    18AUG1973       29   54655      35.1

Orion  Club members high activity          28SEP1938    24OCT1990       89   46966      52.1

Orion  Club members medium activity        20JAN1938    16SEP1992   70059     2806      54.7

Orion Club Goldmembers high activity      16JAN1938    25JUL1988       50      39      50.5

Orion Club Goldmembers low activity       19DEC1973    21JUL1992   70201       13      18.6



!       There are several waysto obtain the number of years between two dates. Two possible techniques aredividing days by 365.25 or using the YRDIF function.

最佳答案

l1i2n3i4n5g 查看完整内容

proc sort data=orion.customer_dim; by Customer_Type BirthDate; run; data orion.customer_dim1; set orion.customer_dim; retain youngest y_ID; format youngest oldest date9. agerange 10.1; by Customer_Type BirthDate; if first.Customer_Type then do; youngest=BirthDate; y_ID=Customer_ID; end; if last.Customer_Type then do; oldest=BirthDate; o_ID=Customer_ID; end; if last.Customer ...
关键词:observations observation Identifying information Techniques SAS
沙发
l1i2n3i4n5g 在职认证  发表于 2016-10-18 20:55:43 |只看作者 |坛友微信交流群
proc sort data=orion.customer_dim;
by Customer_Type BirthDate;
run;

data orion.customer_dim1;
set orion.customer_dim;
retain youngest y_ID;
format youngest oldest date9. agerange 10.1;
by Customer_Type BirthDate;
if first.Customer_Type then
do;
        youngest=BirthDate;
        y_ID=Customer_ID;
end;
if last.Customer_Type then
do;
        oldest=BirthDate;
        o_ID=Customer_ID;
end;
if last.Customer_Type;
agerange=(oldest-youngest)/365.25;
keep Customer_Type oldest youngest o_ID y_ID agerange;
run;

proc sql;
create table orion.customer_dim2 as select Customer_Type,oldest,youngest,o_ID,y_ID,agerange from orion.customer_dim1;
quit;

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-27 03:28