楼主: xiyting
1352 6

Cleaning Messy Data in SAS [推广有奖]

  • 2关注
  • 2粉丝

已卖:10份资源

讲师

70%

还不是VIP/贵宾

-

威望
0
论坛币
9911 个
通用积分
0.9078
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
24963 点
帖子
527
精华
0
在线时间
613 小时
注册时间
2008-6-4
最后登录
2015-7-10

楼主
xiyting 发表于 2012-12-7 10:30:49 |AI写论文
100论坛币
I have the following data stored in a character variable Payment:

87.69/88.20/150.50//183.60195.8987.00/88.35//195.28/47.40/99.2260.34//20.45//325.00/96.45295.00/96.54  Which function should I use to count the number of payment per line to calculate the totalexpense?('/'separate the payment)

最佳答案

pobel 查看完整内容

data have; input payment : $80.; cards; 87.69/88.20/150.50//183.60 195.89 87.00/88.35//195.28/47.40/99.22 60.34//20.45//325.00/96.45 295.00/96.54 ; data want; set have; total_payment=0; i=1; tmp=input(scan(payment,i,"/"),best.); do while (^missing(tmp)); total_payment+tmp; i=i+1; tmp=input(scan(payment,i,"/"),best.); ...
关键词:Cleaning Leaning Clean messy Lean character following function separate payment

沙发
pobel 在职认证  发表于 2012-12-7 10:30:50
data have;
   input payment : $80.;
   cards;
87.69/88.20/150.50//183.60
195.89
87.00/88.35//195.28/47.40/99.22
60.34//20.45//325.00/96.45
295.00/96.54
;

data want;
   set have;
   total_payment=0;
   i=1;
   tmp=input(scan(payment,i,"/"),best.);
   do while (^missing(tmp));
            total_payment+tmp;
            i=i+1;
            tmp=input(scan(payment,i,"/"),best.);
        end;
    N_payment=i-1;
    drop i tmp;
run;





和谐拯救危机

藤椅
Imasasor 发表于 2012-12-7 10:50:51
183.60195.8987.00,多个小数点的数字是什么?
欢迎加入亚太地区第一R&Python数据挖掘群: 251548215;

板凳
xiyting 发表于 2012-12-7 15:22:08
87.69/88.20/150.50//183.60
195.89
87.00/88.35//195.28/47.40/99.22
60.34//20.45//325.00/96.45
295.00/96.54

Which function should I use to count the number of payment per line and to calculate the total Payment?('/'separate the payment)

报纸
xiyting 发表于 2012-12-7 15:22:54
I have the following data stored in a character variable Payment:

87.69/88.20/150.50//183.60
195.89
87.00/88.35//195.28/47.40/99.22
60.34//20.45//325.00/96.45
295.00/96.54

Which function should I use to count the number of payment per line and to calculate the total Payment?('/'separate the payment)

地板
ziyenano 发表于 2012-12-7 15:26:45
data _null_;
test="87.69/88.20/150.50//183.60195.8987.00/88.35//195.28/47.40/99.2260.34//20.45//325.00/96.45295.00/96.54";
num=count(a,'/')+1;
put num=;
run;

7
xiyting 发表于 2012-12-7 15:36:54
How to caculate the total of each line?
Do I need to do the calculation by two steps:
(1) Read each data separated by ‘/’;
(2) Transform the data into numeric type;

Or is there any function to do this take directly?

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-9 05:27