Hi Everyone,
I am importing the attached file into SAS.
All the Date Time are correctly imported.
Somehow, Sas cannot import number.
It skips records of data as well, say the tradetime of 8:00:00 , 16:00:00 and 0:00:00.
Could you please help me to correct my code below?
Thank you so much for your help.
HHC
data mt4;
infile "\book3.txt" firstobs=2
dsd dlm=';' ;
informat date yymmdd10. tradetime time11. ;
input Rate $ TimeFrame $ date tradetime Open Close High Low
adx_main adx_plus adx_minus cci ma50 ma15 ma5 ma25 sar stddev atr demarker force macd_5_15 macd_5_50 macd_15_50 macd_long_main macd_long_signal
macd_medium_main macd_medium_signal macd_short_main macd_short_signal rsi_short rsi_long sto_long_fast sto_long_slow sto_short_fast sto_short_slow mfi_14 mfi_24
fractal_up fractal_down Bband130_main Bband130_upper1 Bband130_lower1 Bband130_upper2 Bband130_lower2 Bband130_upper3 Bband130_lower3
;
format date date9. tradetime time8. ;
run;
You're not using SAS 9.4, are you? Just add the option LRECL=1000 to your INFILE statement and the error should disappear.
Edit:
Explanation: The default of LRECL (actually the system option with this name) has been increased from 256 to 32767 in SAS 9.4 (exception: RECFM=F). Your data had record lengths up to 403, so "SAS went to a new line when INPUT statement reached past the end of a line." This message must have appeared in your SAS log, plus notes about "Invalid data" (and probably a "WARNING: Limit set by ERRORS= option reached. ...") as well as notes "LOST CARD" and "One or more lines were truncated."
Moreover, your dataset would have contained only 52 observations instead of 105, right? In fact, all observations with TRADETIME 0:00, 8:00 and 16:00 were lost due to the errors.
You're not using SAS 9.4, are you? Just add the option LRECL=1000 to your INFILE statement and the error should disappear.
Edit:
Explanation: The default of LRECL (actually the system option with this name) has been increased from 256 to 32767 in SAS 9.4 (exception: RECFM=F). Your data had record lengths up to 403, so "SAS went to a new line when INPUT statement reached past the end of a line." This message must have appeared in your SAS log, plus notes about "Invalid data" (and probably a "WARNING: Limit set by ERRORS= option reached. ...") as well as notes "LOST CARD" and "One or more lines were truncated."
Moreover, your dataset would have contained only 52 observations instead of 105, right? In fact, all observations with TRADETIME 0:00, 8:00 and 16:00 were lost due to the errors.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: