try this. - data a;
- length x1-x7 $30.;
- infile datalines dsd dlm='x';
- input @4 x1 $ +2 x2 $ +2 x3 $ +2 x4 $ +2 x5 $ +2 x6 $ +2 x7 $ +2;
- datalines;
- x1:XiaoMing,x2:1988-03-17 12:00:47,x3:M,x4:Officer,x5:LikeBasketBall,x6:1:14,25:10,67:01,6:23,x7:25SUi
- x1:XiaoHong,x2:1982-01-17 11:04:24,x3:F,x4:Programmer,x5:LikeTableTennis,x6:16:14,25:10,67:01,6:23,x7:26Sui
- x1:XiaoZhu**x2:1990-01-17 05:07:11****x3:M,x4:Athlete,x5:LikeSwim/*/-x6:10:10,05:18,77:06,6:23,x7:23Sui
- x1:XiaoLiang**&x2:1978-09-17 05:07:11***x3:M,x4:Accountant,x5:LikeJogging,x6:11:14,07:18,47:09,6:23,x7:35Sui
- ; run;
- data b; ;
- set a;
- x1 = scan(x1, 1, ',');
- x2 = scan(x2, 1, ',*');
- x3 = scan(x3, 1, ',*');
- x4 = scan(x4, 1, ',*');
- x5 = scan(x5, 1, ',*');
- x6a = scan(scan(x6, 1, ','), 2, ':');
- x6b = scan(scan(x6, 2, ','), 2, ':');
- x6c = scan(scan(x6, 3, ','), 2, ':');
- x6d = scan(scan(x6, 4, ','), 2, ':');
- x7 = scan(x7, 1, ',*');
- datetime=dhms(input(scan(x2, 1, ' '), yymmdd10.), 0,0, input(scan(x2, 2, ' '), time.));
- format date yymmdd10. time time. datetime datetime20.;
- drop date time;
- run;
复制代码
|