Hello, I have a basic looping question inside a dataset to call the import macro based on the total number of import file list given in the source data set. data outdir.imp_lkup_files; length dsn $40 xlsheet $20 filenm $150; infile datalines DSD Delimiter='|'; input dsn $ xlsheet $ filenm $; datalines; outdir.Feb|planf|K:\user\plan_f_20160204 outdir.Mar|planm|K:\user\plan_m_20160322 outdir.Apr|plana|K:\user\plan_a_20160407 ; run; This source dataset contains 3 observations which i have stored in a macro variable ilkup_cnt = 3. Then, i have a macro to import the files into a dataset dynamically. %macro import(out_dsn=,file=,sheet=); PROC IMPORT OUT= &out_dsn. DATAFILE= &file. DBMS=xlsx REPLACE; SHEET=&sheet.; GETNAMES=YES; RUN; %mend import; I am calling this macro in another main macro called file_imp_exp, like below: %macro file_imp_exp(action=); %if %upcase(&action)=IMPORT %then %do; %if &ilkup_cnt. ge 1 %then %do; data _null_; set outdir.imp_lkup_files; %do i = 1 %to &ilkup_cnt.; call symput('imp_dsn',dsn); call symput('imp_sheet',xlsheet); call symput('imp_file',filenm); %import(out_dsn=&imp_dsn.,file=&imp_file.,sheet=&imp_sheet.); %end; run; %end; %end; %else %if %upcase(&action)=EXPORT %then %do; . . . %end; %mend file_imp_exp; %file_imp_exp(action=import); I can see only the 3rd file is imported into a dataset but not the first and second. Can you please suggest how to use the looping between the observations?
... View more