全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
5900 8
2011-05-03
RT,在使用SAS读入CSV数据时,有些数据第一列缺失,后面其实是有数据的,但此时SAS就默认为$1.的格式,结果后面的数据也没有办法读入,不知有什么方法可以解决这个问题。
谢谢
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2011-5-3 22:42:53
读一个文件好像没问题啊。如果是整列缺失,sas定义的长度为$1,如果是列的一部分缺失,长度比最长的字节还多1. sas9.1.3. 楼主是要同时读入多个文件吗?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-5-4 06:50:10
这是因为SAS有一个默认的最大读入行,改大点儿就行了,比如
复制代码
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-5-4 12:21:50
2# sas_user
谢谢。
是读入一个文件,但我的读入的时候不知为什么都是类似情况都读成了$1. 可能与CSV有关,如果是EXCEL不会出现这一情况。但由于数据量有点大,就放在了1个CSV里。但不知为什么会这样
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-5-4 12:24:33
3# junuylia
谢谢
我试一下,不过不太明白这个命令,MISSOVER LINSIZE= 是指定缺失观测的变量的长度吗?是否可以指定数值/字符型?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-5-4 12:59:05
rpg163 发表于 2011-5-3 21:38
RT,在使用SAS读入CSV数据时,有些数据第一列缺失,后面其实是有数据的,但此时SAS就默认为$1.的格式,结果后面的数据也没有办法读入,不知有什么方法可以解决这个问题。
谢谢
It shouldn`t actually happen unless some specific characters or missing value occur at first row. I think you may need to give out the examples as we could do more for you.

I give you a tricky when importing the CSV file into SAS.

For example, I got a CSV with below components:

invid

subjid

phqtotal

mde

10

1001

3

MDE-

10

1002

14

MDE+

10

1003

4

MDE-

10

1004

12

MDE+




Using Proc Import Wizard first import that CSV file back to SAS, save the defaulted program somewhere. It will be something looks like this:

复制代码


However, we could also get a better way and more customized way to import the CSV file!

Go to the log tab, You should see something like this in the Log tab:

复制代码


Well, this is actually how SAS operating inside of the System by this import procedure.

You could copy over the above part SAS code back to use. The most benefit by using this set of code is you could change the format / informat/ length / character or numeric easily! And you can`t realy do that when using "Proc import" code as I show in the first block!

I hope that helps!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群