BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sagulolo
Quartz | Level 8

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.

Shmuel
Garnet | Level 18

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;
sagulolo
Quartz | Level 8

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

 

 

Shmuel
Garnet | Level 18

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); 

 

sagulolo
Quartz | Level 8
Hi Shmuel,

Yes,I have all rows i wanted and EOV variable no more. Now how to import other txt file as now it only import 1 instead of 4 txt file.
Shmuel
Garnet | Level 18

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;

sagulolo
Quartz | Level 8

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;
sagulolo
Quartz | Level 8

Hi Shmuel,

 

Attached the log summary(screenshot as well).LOG.png

Shmuel
Garnet | Level 18

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.

sagulolo
Quartz | Level 8

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 24 replies
  • 2496 views
  • 0 likes
  • 5 in conversation