BookmarkSubscribeRSS Feed
dennis_oz
Quartz | Level 8

Hi is there another way in doing the below. I have displayed input_file below

%macro Import_File(records);
	%if  &records. > 0 %then
		%do;
			/* %do i=1 %to &records.; */
			%put 'enterd loop 1';

			data _null_;
				set input_file;
				call symput ('file_name',strip(file_name));
				select (actual_file_name);

					when ('BABC_EXPORT')                  rc=dosubl('%ImportData_BABC(&file_name,results_in)');

					otherwise;
					STOP;
				end;

				%put 'exited loop 1';
			run;

		%end;
	%else
		%do;
			%put 'loop   6';

			/*			data _null_;*/
			/*				rc=dosubl('%folder_empty_message()');*/
			/*			run;*/
			%put 'exited loop  6 ';
		%end;
%mend;

 this is how the input_file looks.

dennis_oz_0-1655390546448.png

 

 

3 REPLIES 3
Tom
Super User Tom
Super User

What are you trying to do?

If you want to run the macro ImportData_BABC for every file listed in input_file then why not just do that directly?

data _null_;
  set input_file;
  call execute(cats('%nrstr(%importdata_babc)(',file_name,',results_in)'));
run;

If you are trying to do something else then explain what that is.

dennis_oz
Quartz | Level 8
Like baby, I will have other file names like welcome, leaving etc...

How will I handle this? I hope I am clear with my requirement
Tom
Super User Tom
Super User

Add a WHERE statement (or a subsetting IF statement) to eliminate those observations before they can make it to the line that generates to macro call.

 

Perhaps something like this?:

where file_name =: 'BABC_Export' ;

Or perhaps

where index(file_name,'.') and lowcase(scan(file_name,-1,'.'))='csv' ;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 3 replies
  • 1259 views
  • 0 likes
  • 2 in conversation