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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 358 views
  • 0 likes
  • 2 in conversation