g*******r 发帖数: 270 | 1 遇到format input问题,就考虑用LRECL解决,但查了很多资料,没有一个能很简洁明了的
说明LRECL的用法,所以,想在这请教如何用LRECL,在何条件下用....,能不能举个简单的
例子.谢谢! |
|
b*******g 发帖数: 513 | 2 别的我不知道,但在data步中infile一个外部的excel data file, 如果这个外部
excel file列数很长,或者列数不长,但每一个数据,小数点后精确好多位,在这种情
况下如不用lrecl=比较大一个数字这个option,则不能正确读入数据。 |
|
R******d 发帖数: 1436 | 3 有一个sas数据集,有13000行,13000列(实际上就是个square距离矩阵)。我想输出
到一个tab文件。用了proc export,发现行被截断了。读了下输出的code,里面有一个
参数:lrecl=32767。请问如何把这个参数增加到lrecl=32767000(不知道具体多大,
反正挺大的)。直接这么写会报错。
然后我又想了另外一个办法,把这个矩阵转置一下,那么就变成13000*13000列,行就
只有3个数了。想转置好了再输出,应该就没有lrecl的问题了。好比这样:
proc transpose data=distance_matrix out=pair_distance;
var _all_;
by id;
run;
结果巨慢无比,不知道什么时候才能转完全。
大牛支个招吧,多谢了。 |
|
o****o 发帖数: 8077 | 4 the problem is LRECL=256
use LRECL=65534 |
|
w*********e 发帖数: 1 | 5 不知道各位XDJM用SAS有没有碰到LOST CARD的情况?
今天要读进一个csv文件,有将近60个variables:
data;
infile "C:/..../.csv" dsd dlm="," firstobs=2;
input ID $ ......;
run;
结果报告
...LRECL=256
LSOT CARD.
*************
在infile语句加入LRECL=400;貌似能读入所有variables,但是ID却变成数字的形势,
小数点后有两个零。
哪位高手能给答疑?十分感谢! |
|
t********1 发帖数: 799 | 6 lrecl=32767 can not be added in datafile statement.
and i tried options lrecl=32767;
still doesn't work, only 255 cols can be imported into dataset. |
|
F*******1 发帖数: 75 | 7 Site1 - Site1000 are character variables. If I put Site1-Site1000 $ in the
INPUT statement as shown below, only Site1000 is showing as character
variable. Can somebody help me this? Thanks a lot!
data WindSummary;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
infile myfile delimiter = ',' MISSOVER DSD lrecl=102590 firstobs=2;
format DataItem $60. ;
INPUT DataItem $ Site1-Site1000 $;
run; |
|
F*******1 发帖数: 75 | 8 请教一个SAS 数据读入的问题. 我有个样本文件. 见附件.
我只需要第6行到第11行的数据. 在data statement 中, 我可以用firstobs=6 来定位
起事行. 那用什么来定位末位行呢? 我试了lastobs=11 不work. 谢谢!
如果我先读入所有数据,再提取需要的数据.我的sas script 如下. 但结果不对, 第7行
到第11行的数据丢了. 是什么原因呢? 谢谢!
data RT1;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
infile "\\mkscsas01\saswork\20090108_asm_rtmcp_final.csv" delimiter =
',' MISSOVER DSD lrecl=55010 firstobs=6 ;
format Pnode $12. MCPType $12.;
INPUT Pnode $ Zone $ MCPType $ HE1 - HE24;
run; |
|
b*******g 发帖数: 513 | 9 用sas读入excel file 时,当excel 的column多于256时,其余的列是不能显示出来
的。这时用option lrecl就可解决问题。那么用R读入column多于256的excel file
时该怎么办?谢了! |
|
y****1 发帖数: 400 | 10 原来的code重新run了一次,log如下:
259304 data _null_;
259305 set Imp.pedfile;
259306 file 'C:\Documents and Settings\User\My Documents\Imputation
paper\Chr21.ped';
259307 put Family_ID Individual_ID Father_ID Mother_ID Sex Col1-
Col16179;
259308 run;
NOTE: The file 'C:\Documents and Settings\User\My Documents\Imputation
paper\Chr21.ped' is:
File Name=C:\Documents and Settings\User\My Documents\Imputation
paper\Chr21.ped,
RECFM=V,LRECL=256
NOTE: 6072 records were written to th |
|
o****o 发帖数: 8077 | 11 我跑的结果:
NOTE: The infile "c:\test.txt" is:
File Name=c:\test.txt,
RECFM=V,LRECL=256
NOTE: 3 records were read from the infile "c:\test.txt".
The minimum record length was 9.
The maximum record length was 10.
NOTE: The data set WORK.HOMEWORK has 2 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
looks like the answer is not correct |
|
t**i 发帖数: 688 | 12 我的数据是tab格式化的,几万列。都是字符变量,尽管是数字构成的。请教如何确保
SAS读入的时候采用字符型变量格式?
下面这个好像不行。
infile “myfile”firstobs=1 lrecl=1000000 truncover;
input v1 - v50000 $ ; |
|
t**i 发帖数: 688 | 13 Example code? Like the following?
data test;
infile 'myfile' firstobs=1 dlm=',' lrecl=10000000 truncover;
length v1 - v50000 :$12 ;
input v1 - v50000;
run; |
|
j******o 发帖数: 127 | 14 TRUNCOVER
Forces the INPUT statement to stop reading when it gets to the end of a
short line. This option will not skip information.
PAD
Pads short lines with blanks to the length of the LRECL= option.
MISSOVER
Sets all empty vars to missing when reading a short line. However, it can
also skip values. |
|
s****e 发帖数: 1180 | 15 我知道列是能最多显示256列,多出去了列用lrecl这个option,还能读到sas里,那么
行呢?望达人解释,谢谢! |
|
A****t 发帖数: 141 | 16 1000?
data one;
infile "...." dlm=',' lrecl=100000;
input var1-var1000;
run; |
|
g**a 发帖数: 2129 | 17 data one;
infile 'filepath' LRECL=150000;
input @'(''' Var1 10. @@;
run;
proc print data=one;
run;
Assuming the length of the number is 10
change the record length accordingly.
the
,( |
|
c**d 发帖数: 104 | 18 Suppose you have a lot of excel files under H:\Temp
/* get excel names */
filename myxls 'dir "H:\Temp" /b' LRECL=5000;
data myfile;
infile myxls length = len;
input fname $200. len;
run;
/* save each into a macro variable */
proc sql;
select fname into :a1 - :a9999
/* do loop to input excel */ |
|
b****e 发帖数: 906 | 19 just figured out, here to share with you,
add LRECL= option behind the infile statement |
|
b*******g 发帖数: 513 | 20 怎样在R里读入一个列数超过256列的csv,excel文件?大家知道csv,excel文件最多显示256列。多于256列的都遮住了。同学说是用read.table硬读,我试了一下不行。不用加什么options吗?象SAS里用lrecl=1000000(anyway一个比较大的数)?多谢答复! |
|
D******n 发帖数: 2836 | 21 are u talking about R or Excel? so confused.
It is no problem doing that in R.
显示256
列。多于256列的都遮住了。同学说是用read.table硬读,我试了一下不行。不用加什
么options
吗?象SAS里用lrecl=1000000(anyway一个比较大的数)?多谢答复! |
|
O*****y 发帖数: 222 | 22 csv files are basically text files. read.table, scan, read.csv all can read
in data from csv files.
显示256列。多于256列的都遮住了。同学说是用read.table硬读,我试了一下不行。不
用加什么options吗?象SAS里用lrecl=1000000(anyway一个比较大的数)?多谢答复! |
|
d******g 发帖数: 130 | 23 read.csv has no problem reading this dataset. I used it all the time to
input 400+ columns.
显示256列。多于256列的都遮住了。同学说是用read.table硬读,我试了一下不行。不
用加什么options吗?象SAS里用lrecl=1000000(anyway一个比较大的数)?多谢答复! |
|
b*****e 发帖数: 223 | 24 数据有 500 columns,大多数是 numeric,个别是 char。其实只需要其中十个左右
columns。我想这样弄的,试图把所有 columns 都读成 char,但是不行。有没有什么
好办法?我不想把 char column 一个个人为找出来单独列出来读,因为其实大部分都
用不到。
或者,有什么只读我需要的那些 columns 的读数据的方法?以前没读过这么多列的数据
,没经验
data ALLPAGE;
infile "\....\My Documents\MYDATA.txt" delimiter='09'x
firstobs=4 obs=1410 dsd lrecl=10000 missover;
input COL1-COL500 ; /* 这样 char col 都是空白 */
input COL1-COL500 $ ; /* 这样不行? */
input COL1-COL222 COL223 $ ..... COLxxx-COL500; /* 嫌麻烦 */
run; |
|
h******e 发帖数: 1791 | 25 FILENAME dirfile PIPE "dir ""C:\temp"" /b" LRECL=200;
请问以上语句里的“dir ”是起什么作用的?谢谢。 |
|
a****g 发帖数: 8131 | 26 after datafile, add lrecl=32767
the |
|
t******m 发帖数: 58 | 27 郁闷了。。楼上2为大虾的办法我之前都尝试过,都不行,sex都是missing的。我现在
贴点code出来,恳请大虾继续指点。。。
OPTIONS LS=132 PS=10000 NOCENTER;
/*
Fromat
DIN=DIN
CD=Claim Date
DS=Days Supply
NU=Number of Units
UP=UNIT_PRICE
ICP=Ingredient Cost Paid
DFP=Dispensing Fee Paid
TAP=Total Amount Paid
RPS=Random Pharmacy Store
RPN=Random Patient Number
PDOB=Patient DOB
PG=Patient Gender
*/
data f1;
/*INFORMAT CD YYMMDD13.2; FORMAT CD YYMMDD10.;
INFORMAT PDOB YYMMDD13.2; FORMAT PDOB YYMMDD10.;*/
INFORMAT UP ICP DFP TAP DOLLAR7.2; FORMAT UP ICP DFP... 阅读全帖 |
|
x*******u 发帖数: 500 | 28 从数据上看第一个变量的长度是10, 但是用你的code读出来结果是这样的:
char1 char2 char3
1 0 / 3 0 0 0 9 .1 4 1
中间还是有空格。
我用proc import读入数据后, log里面是这样的:
data WORK.READASC ;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
infile 'myfile.csv' delimiter = ',' MISSOVER DSD lrecl=32767 firstobs=7 ;
informat VAR1 $21. ;
informat VAR2 $23. ;
informat VAR3 $9. ;
format VAR1 $21. ;
format VAR2 $23. ;
format VAR3 $9. ... 阅读全帖 |
|
x*******u 发帖数: 500 | 29 谢谢大家的帮助, 最后是SAS Technical Support 解决了问题。
It looks like you may have a Unicode file that has a hex '00' between each
character. Are you using PROC IMPORT to read the file? Use a FILENAME
statement to create a fileref for the file you want to read. On the
FILENAME statement add the ENCODING=UNICODE option. Then in the PROC IMPORT
, use DATAFILE=.
For example,
filename temp 'c:\temp\qualityinfo.csv' encoding="unicode" lrecl=32767;
proc import datafile=temp out=quality dbms=csv ... 阅读全帖 |
|
j******o 发帖数: 127 | 30 昨天刚写了几段code,不过是对csv的,请你改一下用在Excel文件上吧。中间有些地方
可能不太完善(比如文件名不能有空格等),欢迎改进及简化。
----------------------------------------------------------------
libname backup "C:\Documents and Settings\Ying\Desktop\Test";
filename blah pipe 'dir "C:\Documents and Settings\Ying\Desktop\Test\*.csv"
';
data dirlist;
infile blah truncover lrecl=200;
input line $200. ;
if upcase(substr(line, 1, 9))='DIRECTORY' then call symput('direc', trim
(substr(line, 14, length(line))));
if input(substr(line,1,10), ??... 阅读全帖 |
|
s******y 发帖数: 352 | 31 %let dirpath=d:;
filename csvfile pipe "dir /b &dirpath.\*.csv";
data allcsv;
infile csvfile lrecl=1000;
input;
fname=catx('',"&dirpath.",_infile_);
infile dummy filevar=fname filename=myfile end=done firstobs=4
dsd truncover;
do while(not done);
input date :date9. Tier :$50. Ccy :$50.
Doc :$50. Sd1y :percent. Sd2y :percent.;
output;
end;
put 'Done with ' myfile=;
run;
external |
|
R******d 发帖数: 1436 | 32 我有一个很大的数据集,要计算25000个变量和将近3000个变量之间的相关性。
结果出来,发现有很多空行没有相关系数,比如L19, L33这样的。如果把为空的数据点
(L19, L33)单独拿出来,则可以算出结果。请问这是什么问题?
谢谢了。
data mydata;
infile "/dir/file" firstobs=2 lrecl=2000000;
input C1-C25000 L1-L3000;
run;
proc corr data=mydata outp=corr(where=(_NAME_ ne "") drop=_TYPE_) noprint;
var C1-C25000;
with L1-L3000;
run;
proc export data=corr
outfile="/dir/out"
dbms=tab replace;
run; |
|
p***7 发帖数: 535 | 33 Data facilit;
Infile "/analytics/ft.txt" DLM='|' dsd truncover lrecl=4096;
Input fac_id hosp_name $ long_name $ address1 open_date closed_date ;
run;
Data is below
fac_id | hosp_name|long_name |address1 |open_date |
closed_date
112060360 | mcennter |nald Center| 7989 Linda Vista Rd|10/01/2011|11/01/
2015
Whenever it reads the open_data and closed_date, it says not correct format
for them.
tried informat mmddyy10, but still doesn't work.
Help please!
Thanks |
|