我使用下面的代码将数据从csv格式导入到SAS中。但是,如图所示,创建的数据集中的数据列在错误的行中。投标规模的实际数据位于bid_price中,而bid_size中的数据缺失。由于某些原因,我不能使用File>Import数据或proc import。因此,有人能帮我检查我使用的代码吗?

data WORK.want ;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
infile "E:\N69853943.csv" /*obs = 10*/
delimiter = ',' MISSOVER DSD lrecl=32767 firstobs=2 ;
informat _RIC $25. ;
informat Date_L_ best32. ;
informat Time_L_ time20.3 ;
informat Type $13. ;
informat Ex_Cntrb_ID $1. ;
informat LOC $1. ;
informat Price best32. ;
informat Volume best32. ;
informat Market_VWAP $1. ;
informat Buyer_ID $3. ;
informat Bid_Price best32. ;
informat Bid_Size best32. ;
informat No__Buyers $1. ;
informat Seller_ID $3. ;
informat Ask_Price best32. ;
informat Ask_Size best32. ;
format _RIC $25. ;
format Date_L_ best32. ;
format Time_L_ time20.3 ;
format Type $13. ;
format Ex_Cntrb_ID $1. ;
format LOC $1. ;
format Price best32. ;
format Volume best32. ;
format Market_VWAP $1. ;
format Buyer_ID $3. ;
format Bid_Price best32. ;
format Bid_Size best32. ;
format No__Buyers $1. ;
format Seller_ID $3. ;
format Ask_Price best32. ;
format Ask_Size best32. ;
input
_RIC $
Date_L_
Time_L_
Type $
Ex_Cntrb_ID $
LOC $
Price
Volume
Market_VWAP $
Buyer_ID $
Bid_Price
Bid_Size
No__Buyers $
Seller_ID $
Ask_Price
Ask_Size
;
if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection macro variable */
run;发布于 2017-06-26 21:40:38
您的代码有一个额外的变量LOC,与Excel文件相比列出了LOC,因此您的数据被推送到一个字段上。它在E/F列之间。
请注意,前面的变量是为表示而切断的,但是它有一个/,并且可能有一个逗号,这使得PROC导入假设您有另一个变量。删除LOC变量以正确读取文件。
您还可能希望使用TRUNCOVER而不是MISSOVER。
https://stackoverflow.com/questions/44766875
复制相似问题