- 阅读权限
- 255
- 威望
- 0 级
- 论坛币
- 210 个
- 通用积分
- 6.3548
- 学术水平
- 3 点
- 热心指数
- 4 点
- 信用等级
- 1 点
- 经验
- 2503 点
- 帖子
- 51
- 精华
- 0
- 在线时间
- 144 小时
- 注册时间
- 2015-6-15
- 最后登录
- 2023-1-3
|
- data stock1990;
- input stkcd$ stkcd1$ link;
- cards;
- 0001 0002 1
- 0002 0001 1
- 0002 0003 1
- 0003 0002 1
- ;
- run;
- proc sql;
- create table matrix1990 as
- select a,max(_0001) as _0001,max(_0002) as _0002,max(_0003) as _0003 from
- (select "0001" as a,(case when stkcd1="0001" then link else . end) as _0001,
- (case when stkcd1="0002" then link else . end) as _0002,
- (case when stkcd1="0003" then link else . end) as _0003 from stock1990 where stkcd="0001"
- union
- select "0002" as a,(case when stkcd1="0001" then link else . end) as _0001,
- (case when stkcd1="0002" then link else . end) as _0002,
- (case when stkcd1="0003" then link else . end) as _0003 from stock1990 where stkcd="0002"
- union
- select "0003" as a,(case when stkcd1="0001" then link else . end) as _0001,
- (case when stkcd1="0002" then link else . end) as _0002,
- (case when stkcd1="0003" then link else . end) as _0003 from stock1990 where stkcd="0003"
- )
- group by a;
- quit;
- data a;
- do i=1 to 28;
- indat=cats("stock",1989+i);
- outdat=cats("matrix",1989+i);
- output;
- end;
- run;
- proc sql;
- select indat into:indat separated by "|" from a;
- select outdat into:outdat separated by "|" from a;
- quit;
- %put &indat. &outdat.;
- %macro loop();
- %do i=1 %to 28;
- proc sql;
- create table %qscan(&outdat.,&i.,"|") as
- select a,max(_0001) as _0001,max(_0002) as _0002,max(_0003) as _0003 from
- (select "0001" as a,(case when stkcd1="0001" then link else . end) as _0001,
- (case when stkcd1="0002" then link else . end) as _0002,
- (case when stkcd1="0003" then link else . end) as _0003 from %qscan(&indat.,&i.,"|") where stkcd="0001"
- union
- select "0002" as a,(case when stkcd1="0001" then link else . end) as _0001,
- (case when stkcd1="0002" then link else . end) as _0002,
- (case when stkcd1="0003" then link else . end) as _0003 from %qscan(&indat.,&i.,"|") where stkcd="0002"
- union
- select "0003" as a,(case when stkcd1="0001" then link else . end) as _0001,
- (case when stkcd1="0002" then link else . end) as _0002,
- (case when stkcd1="0003" then link else . end) as _0003 from %qscan(&indat.,&i.,"|") where stkcd="0003"
- )
- group by a;
- quit;
- %end;
- %mend;
- %loop();
复制代码
|
-
总评分: 经验 + 60
查看全部评分
|