SAS中文论坛

标题: 请教高手一个数据处理问题 [打印本页]

作者: today2015    时间: 2015-6-5 17:55
标题: 请教高手一个数据处理问题
vs_17001_crn
pool_7001_crn
10.1.66.19:7001
10.1.66.104:7001
vs_17002_cognos8
pool_7002_cognos8
10.1.66.19:7002
10.1.66.104:7002
vs_17003_cognos8
pool_7003_cognos8
10.1.66.19:7003
10.1.66.104:7003
vs_17080_cognosreport
pool_17080_cognosreport
10.1.66.18:80

将上述文本文件转换成表格,格式如下:
  
VS
  
POOL
Site
vs_17001_crn
pool_7001_crn
10.1.66.19:7001
  
10.1.66.104:7001






作者: BioSas    时间: 2016-5-14 01:04

data Output_1 (label="Outputted Three Columns Not Aligned");
input Txt_Field : $23.;
if upcase(substr(Txt_Field,1,2))='VS' then VS=Txt_Field;
else if upcase(substr(Txt_Field,1,2))='PO' then Pool=Txt_Field;
else Site=Txt_Field;
drop Txt_Field;
datalines;
vs_17001_crn
pool_7001_crn
10.1.66.19:7001
10.1.66.104:7001
vs_17002_cognos8
pool_7002_cognos8
10.1.66.19:7002
10.1.66.104:7002
vs_17003_cognos8
pool_7003_cognos8
10.1.66.19:7003
10.1.66.104:7003
vs_17080_cognosreport
pool_17080_cognosreport
10.1.66.18:80
;
run;

data VS POOL Site;
input Txt_Field : $23.;
if upcase(substr(Txt_Field,1,2))='VS' then output VS;
else if upcase(substr(Txt_Field,1,2))='PO' then  output POOL;
else  output Site;
datalines;
vs_17001_crn
pool_7001_crn
10.1.66.19:7001
10.1.66.104:7001
vs_17002_cognos8
pool_7002_cognos8
10.1.66.19:7002
10.1.66.104:7002
vs_17003_cognos8
pool_7003_cognos8
10.1.66.19:7003
10.1.66.104:7003
vs_17080_cognosreport
pool_17080_cognosreport
10.1.66.18:80
;
run;

data  Output_2 (label="Outputted Three Columns Aligned");
merge  VS(rename=(Txt_Field=VS))
       POOL(rename=(Txt_Field=Pool))
       Site(rename=(Txt_Field=Site));
run;





欢迎光临 SAS中文论坛 (https://mysas.net/forum/) Powered by Discuz! X3.2