由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - 求问SAS技术问题,one row to multiple row
相关主题
SAS code 问题新手求教一个简单的SAS问题
ask SAS codeA SAS question, please help!
SAS helpSAS 问题
请教个SAS问题Sas问题, 有包子
[SAS] row merging请教版上高人一个SAS编程问题
工作中的SAS 编程请教急!一个简单的SAS问题,请大家帮帮解释一下!多谢!
工作中SAS问题 —另一个问题请教!请教SAS问题
sas question请教一sas code
相关话题的讨论汇总
话题: 260话题: 190话题: 32话题: 45话题: starting
进入Statistics版参与讨论
1 (共1页)
f****r
发帖数: 1140
1
我现在有这样的input:
customer       account
32 190
45 260
想要这样的output:
customer account month starting ending
32 190 1 a b
32 190 2 b c
32 190 3 c d
32 190 4 d e
32 190 5 a b
32 190 6 b c
32 190 7 c d
32 190 8 d e
32 190 9 a b
32 190 10 b c
32 190 11 c d
32 190 12 d e
32 190 13 a b
32 190 14 b c
32 190 15 c d
45 260 1 a b
45 260 2 b c
45 260 3 c d
45 260 4 d e
45 260 5 a b
45 260 6 b c
45 260 7 c d
45 260 8 d e
45 260 9 a b
45 260 10 b c
45 260 11 c d
45 260 12 d e
45 260 13 a b
45 260 14 b c
45 260 15 c d
对于每个客户来说,每个月的starting 等于上个月的ending。但是start
ing, ending要一个月一个月横向算出来,然后pass到下一个月。
请问各位大侠高手,有啥好方法吗?多谢了。。
另外,大家常去的问SAS技术问题的论坛是什么?人气旺,回答问题及时的那种。多
谢!!
s*********n
发帖数: 20
2
Does this work? There might be other easier solution.
data input;
do month=1 to 15;
customer=32;account=190;output;
end;
do month=1 to 15;
customer=42;account=260;output;
end;
run;
proc format;
value f_sta_end 1='a'
2='b'
3='c'
4='d'
5='e' ;
run;
data output;
retain starting 1 ending 2;
set input;
by customer;
if first.customer=1 or ending=5 then do;
starting=1;
ending=2;
end;
else do;
starting=ending;
ending=starting+1;
end;
format starting ending f_sta_end. ;
run;

【在 f****r 的大作中提到】
: 我现在有这样的input:
: customer       account
: 32 190
: 45 260
: 想要这样的output:
: customer account month starting ending
: 32 190 1 a b
: 32 190 2 b c
: 32 190 3 c d
: 32 190 4 d e

j******o
发帖数: 127
3
第一个月的starting信息缺失?Ending和starting之间的关系缺失?用do loop应该可
以得到你要的,试试下面的思路:
data have;
input customer account;
datalines;
32 190
45 260
;
run;
%let mth=15;
data one;
set have;
do i=1 to &mth;
month=i;
if month=1 then do; starting=1; ending=starting*1.25; end;
else do;starting=ending; ending=starting*1.25;end;
output;
end;
drop i;
run;
1 (共1页)
进入Statistics版参与讨论
相关主题
请教一sas code[SAS] row merging
求教 SAS数据转化工作中的SAS 编程请教
a SAS question for best solution工作中SAS问题 —另一个问题请教!
【SAS求问】用SAS作图,然后存入Excel文件sas question
SAS code 问题新手求教一个简单的SAS问题
ask SAS codeA SAS question, please help!
SAS helpSAS 问题
请教个SAS问题Sas问题, 有包子
相关话题的讨论汇总
话题: 260话题: 190话题: 32话题: 45话题: starting