Reputation: 307
I used following code to import data from csv format into SAS. However, the data in the created dataset is in wrong row as shown in the pic. The actual data in bid size is located in bid_price and the data in bid_size is missing. Due to some reason, I cannot use File>Import data or proc import
. Hence, could anyone help me check the code I used?
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;
Upvotes: 0
Views: 225
Reputation: 21274
Your code has an extra variable, LOC, listed compared to the Excel file and thus your data is pushed over one field. It's between column E/F.
Note that the variable right before, is cut off for presentation but it has a / and may have a comma which caused PROC IMPORT to assume you had another variable. Remove the LOC variable to read the file in correctly.
You may also want to use the TRUNCOVER instead of MISSOVER.
Upvotes: 1