标题: 求助:如何读取不太规则的数据 [打印本页] 作者: shiyiming 时间: 2008-2-1 16:31 标题: 求助:如何读取不太规则的数据 Name,Room,Job,Id
"Alvarez, Joe",204,Development,4327
"Brown, Ann",112,Publications,2587
"Krueger, John", ,Sales,3456
"Miller, Rick",865,Training,2145
"Nguyen, Len",821,Marketing,3678
上面的文件写在一个asv文件中,如何将文件读到数据集合中?
一般的用分隔符固定格式写入就可以了,但是这个asv前面有”和,
如何读出Miller Rick 865 Training 2145
请大侠帮助作者: shiyiming 时间: 2008-2-1 17:14 标题: Re: 求助:如何读取不太规则的数据 [code:3kxiu5sb]PROC IMPORT OUT= test
DATAFILE= "C:\test.csv"
DBMS=CSV REPLACE;
GETNAMES=YES;
DATAROW=2;
RUN;[/code:3kxiu5sb]
或者
[code:3kxiu5sb]data test;
infile 'C:\test.csv' delimiter = ',' MISSOVER DSD lrecl=32767 firstobs=2 ;
input Name $ Room Job $ Id;
run;[/code:3kxiu5sb]作者: shiyiming 时间: 2008-2-1 19:06 标题: Re: 求助:如何读取不太规则的数据 感谢搂住的帮助 <!-- s:D --><img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" /><!-- s:D --> ,能问一下下面
MISSOVER DSD lrecl=32767 有什么作用 ,您是如何将冒号去掉的?
MISSOVER 什么意思DSD是不是连接两个空格的 lrecl=32767什么意思呀?作者: shiyiming 时间: 2008-2-2 09:19 标题: Re: 求助:如何读取不太规则的数据 SAS HELP都有详细解释,或者最简单的方法就是你试着去掉这些options,看看有什么区别。
[quote:2g8ibmvi]MISSOVER
prevents an INPUT statement from reading a new input data record if it does not find values in the current input line for all the variables in the statement. When an INPUT statement reaches the end of the current input data record, variables without any values assigned are set to missing.[/quote:2g8ibmvi]
[quote:2g8ibmvi]DSD (delimiter-sensitive data)
specifies that when data values are enclosed in quotation marks, delimiters within the value be treated as character data. The DSD option changes how SAS treats delimiters when you use LIST input and sets the default delimiter to a comma. When you specify DSD, SAS treats two consecutive delimiters as a missing value and removes quotation marks from character values.[/quote:2g8ibmvi]
[quote:2g8ibmvi]LRECL=logical-record-length
specifies the logical record length.[/quote:2g8ibmvi]作者: shiyiming 时间: 2008-2-2 09:59 标题: Re: 求助:如何读取不太规则的数据 The default value of input buffer in SAS in 256 bytes, set input buffer = the maximum length
of line in external file 32767 by LRECL to assure SAS can read every data per line.
missover option assigns missing values when variables is greater than data and prevent
SAS to read next line to get data and fill in the extra variables.
DSD tells SAS not to read quotation marks as part of data and to treat two delimiter as
a missing value.