I am using SAS University edition .
I have placed the 2 CSV files with different name in the same "my folder" and I want it to be imported to sas. I am trying to create macros for importing multiple csv or xls files .
my location of the file is "/folders/myshortcuts/myfolder/DS1"
Please suggest as to which part of the code is wrong ?
I have tried the below code but I am getting the error .
Code
%macro drive(dir,ext);
%local cnt filrf rc did memcnt name;
%let cnt=0;
%let filrf=mydir;
%let rc=%sysfunc(filename(filrf,&dir));
%let did=%sysfunc(dopen(&filrf));
%if &did ne 0 %then %do;
%let memcnt=%sysfunc(dnum(&did));
%do i=1 %to &memcnt;
%let name=%qscan(%qsysfunc(dread(&did,&i)),-1,.);
%if %qupcase(%qsysfunc(dread(&did,&i))) ne %qupcase(&name) %then %do;
%if %superq(ext) = %superq(name) %then %do;
%let cnt=%eval(&cnt+1);
%put %qsysfunc(dread(&did,&i));
proc import datafile="&dir\%qsysfunc(dread(&did,&i))" out=dsn&cnt
dbms=csv replace;
run;
%end;
%end;
%end;
%end;
%else %put &dir cannot be open.;
%let rc=%sysfunc(dclose(&did));
%mend drive;
%drive(/folders/myshortcuts/myfolder/DS1,csv)
Error in LOG
Change the PROC IMPORT line to use &dir/%qsysfunc, instead of &dir\%qsysfunc.
proc import datafile="&dir/%qsysfunc(dread(&did,&i))" out=dsn&cnt
Change the PROC IMPORT line to use &dir/%qsysfunc, instead of &dir\%qsysfunc.
proc import datafile="&dir/%qsysfunc(dread(&did,&i))" out=dsn&cnt
thanks for your prompt reply it works perfectly
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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 save with the early bird rate—just $795!
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.