Hi Tom,
I found a special charater(Ankh) from the text file and that the one causing the empty column in the dataset. Really thank for your code and it work for my case.
Thank you for your guidance and time.
Would you try:
filename fn pipe 'dir C:\Users\Desktop\testing\*.txt /s /b';
data new;
infile fn EOV=Done;
input name:&$100.;
infile in filevar=name end=last firstobs=11 missover dsd ;
retain Grp_AC No Batch_no TRX_CODE Amount Block_Code ;
format Grp_AC $char11.
Batch_no $char14.
Block_Code $char4.
No $char16.
TRX_CODE $char3.;
DO UNTIL (EOV); /* line added */
do while(not last);
Input Grp_AC $ 1-24 @;
file_name = scan( scan( name, -1, '\' ), 1, '.' );
input Grp_AC $ 1-24 No $ 31-48 Batch_no $ 52-66 TRX_CODE $ 72-76 @86 Amount trailsgn16. Block_Code $ 110-113 ;
/*** statement changed according to @Tom's suggestion ***/
if NOT (Grp_AC = 'Grp A' or Grp_AC = '' or Grp_AC = 'OVER' or Grp_AC = 'Total Count')
then output;
end;
last=0; /* reseting for next file */
END; /* ending loop until eov */
run;
Hi Shmuel,
try the code it actually infile 1 txt file only, then it stop, won't proceed to other txt file. There another variable name "EOV" appear in dataset which this variable not exist in txt file.
Thanks
1) have you got all rows from the first text file?
2) soory, I had a typo. I defined
infile fn EOV=Done;
therefore change from:
DO UNTIL (EOV);
to
DO UNTIL (Done);
I cannot simulate and run your code nor guess where is the problem.
I believe it should read all 4 files.
Have you reset last=0; between end of 'do until(last)' and end of 'do until(done)'.
please post the full log running with options source;
Hi Shmuel,
Apologize for inconveniece caused, attached the 2 txt file and code.
filename fn pipe 'dir C:\Users\Desktop\testing\*.txt /s /b';
data new;
infile fn EOV=Done;
input name:&$100.;
infile in filevar=name end=last firstobs=11 missover dsd ;
retain Grp_AC No Batch_no TRX_CODE Amount Block_Code ;
format Grp_AC $char11.
Batch_no $char14.
Block_Code $char4.
No $char16.
TRX_CODE $char3.;
DO UNTIL (Done); /* line added */
do while(not last);
Input Grp_AC $ 1-24 @;
file_name = scan( scan( name, -1, '\' ), 1, '.' );
input Grp_AC $ 1-24 No $ 31-48 Batch_no $ 52-66 TRX_CODE $ 72-76 @86 Amount trailsgn16. Block_Code $ 110-113 ;
/*** statement changed according to @Tom's suggestion ***/
if NOT (Grp_AC = 'Grp A' or Grp_AC = '' or Grp_AC = 'OVER' or Grp_AC = 'Total Count') then output;
end;last=0; /* reseting for next file */
END; /* ending loop until eov */
run;
Hi Shmuel,
Attached the log summary(screenshot as well).
In your summary log the is a message of LOST CARD.
One more try - replace the MISSOVER option with TRUNCOVER option
with hope it will help, otherwise maybe someone else will be able to help.
Hi Shmuel,
Replace MISSOVER option with TRUNCOVER option but same problem happen. Only 4 records output and read 1 txt file only,
Summary log same message got LOST CARD.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.