楼主: funwin
5075 30

请教 数据导入问题 [推广有奖]

21
funwin 发表于 2009-8-18 23:03:20
高手 果然是高手 ! 多谢指点 。

再请教一事, 刚才在处理数据时,又碰到如下问题:
165  data n.tab3_ba;
1166  set n.tab3;
1167  array dt{*} _:;
ERROR: All variables in array list must be the same type, i.e., all numeric or character.
ERROR: All variables in array list must be the same type, i.e., all numeric or character.
ERROR: All variables in array list must be the same type, i.e., all numeric or character.
ERROR: All variables in array list must be the same type, i.e., all numeric or character.
1168  do i=1 to dim(dt);
在处理 tab1, tab2都没有问题, 就处理到tab3, 出现了 。
变量必须相同格式吗? 好像tab1 tab2里的格式 和tab3里的格式是一样的

怎么处理这种问题? 谢谢!

22
jingju11 发表于 2009-8-18 23:50:48
变量必须相同格式吗?
Yeah. Elements in the  array have to be in the same type, either numeric or character. 好像tab1 tab2里的格式 和tab3里的格式是一样的
You can use proc contents to see the variable info, such as type, format, etc.

For tackling the problem you mentioned, it will spend much time on that.
if only few of them are different types, you could change the type one by one.
Of note, when you merge by differnt data set, the same-name variables have to be in the same type too.

I suggest, you can change the type in EXCEL before reading into SAS. For example, change all variables to text format.

23
sushe1527 发表于 2009-8-18 23:51:43
你直接把五个excel打包贴上来得了 麻烦还得猜
未命名.gif

24
jingju11 发表于 2009-8-19 00:01:48
其实, 你只要把每个表格的信息(从 proc contents 来)贴出就行了。我想许多人都可以帮助解决问题了。

25
yongyitian 发表于 2009-8-19 01:19:27
23楼, the video is fun. Every time click "RUN", there is a black DOS window jump out. You have to close it every time. How that happens?

26
sushe1527 发表于 2009-8-19 01:39:43
yongyitian 发表于 2009-8-19 01:19
23楼, the video is fun. Every time click "RUN", there is a black DOS window jump out. You have to close it every time. How that happens?
no ,not every time, i guess this macro programe may use  windows's cmd part.

27
yongyitian 发表于 2009-8-19 06:38:04
sushe1527 发表于 2009-8-19 01:39
yongyitian 发表于 2009-8-19 01:19
23楼, the video is fun. Every time click "RUN", there is a black DOS window jump out. You have to close it every time. How that happens?
no ,not every time, i guess this macro programe may use  windows's cmd part.
Thanks for reply.

28
funwin 发表于 2009-8-19 18:19:23
22# jingju11

用 proc contents 终于找到原因了 :
128_003_7_31Num8 2003-7-31
129_003_8_29Num8 2003-8-29
130_003_9_30Num8 2003-9-30
143_004_10_29Char1$1.$1.2004-10-29
144_004_11_30Char1$1.$1.2004-11-30
145_004_12_31Char1$1.$1.2004-12-31
134_004_1_30Num8 2004-1-30
135_004_2_27Num8 2004-2-27
136_004_3_31Num8 2004-3-31
137_004_4_30Num8 2004-4-30
138_004_5_31Num8 2004-5-31
139_004_6_30Num8 2004-6-30
140_004_7_30Num8 2004-7-30
141_004_8_31Num8 2004-8-31
142_004_9_30Num8 2004-9-30
155_005_10_31Num8 2005-10-31
156_005_11_30Num8 2005-11-30
157_005_12_30Num8 2005-12-30
146_005_1_31Char1$1.$1.2005-1-31
147_005_2_28Num8 2005-2-28

有四个值 是char的

也把我原始excel表格附上,看是在excel上改方便?还是 用sas语句 更改这四个值的格式?
多谢各位 的帮助

29
jingju11 发表于 2009-8-19 20:43:43

004_11_30=Dt_004_11_30

28# funwin


data tab_;
set tab (rename=(_004_10_29=Dt_004_10_29
          _004_10_30=Dt_004_10_30
          _004_10_31=Dt_004_10_31
          _005_1_31=Dt_005_1_31
          ));
_004_10_29=input(Dt_004_10_29,1.); *change to numeric;
_004_10_30=input(Dt_004_10_30,1.);
_004_10_31=input(Dt_004_10_31,1.);
_005_1_31  =input(Dt_005_1_31,  1.);
array Dt{*} _:;
....
;
drop Dt_:;
run;

30
jingju11 发表于 2009-8-19 20:48:05
data tab_;
set tab (rename=(_004_10_29=Dt_004_10_29
          _004_11_30=Dt_004_11_30
          _004_12_31=Dt_004_12_31
          _005_1_31=Dt_005_1_31
          ));
_004_10_29=input(Dt_004_10_29,1.); *change to numeric;
_004_11_30=input(Dt_004_11_30,1.);
_004_12_31=input(Dt_004_12_31,1.);
_005_1_31  =input(Dt_005_1_31,  1.);
array Dt{*} _:;
....
;
drop Dt_:;
run;
*sorry, made the mistake on some dates;

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-1 04:43