I found a sample program on the SAS website to import all .csv files from a directory here: https://documentation.sas.com/?docsetId=mcrolref&docsetTarget=n0ctmldxf23ixtn1kqsoh5bsgmg8.htm&docse...
I am trying to import several csv files using this macro. The only thing I've changed is the filepath reference when the macro is invoked at the end of the code and I get an error message saying "WARNING: Apparent symbolic reference CSV not resolved." I thought that inputting csv just told the macro what file extension is used for all the files in the folder. I know this warning message is usually the result of trying to use a global variable that has never been defined. I didn't think I was referencing a variable named "CSV." Does anyone know why I might be getting this error? Thanks!
%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(c:\temp,csv)
Hi @eb175 A quick look makes me spot
%if %superq(ext) = %superq(&name) %then %do; /*is this error as the syntax should be %superq(name) without the the ampersand &*/
Please show your log, including the error. You may want to add the macro debugging options as well.
options mprint symbolgen;
Hi @eb175 A quick look makes me spot
%if %superq(ext) = %superq(&name) %then %do; /*is this error as the syntax should be %superq(name) without the the ampersand &*/
@SAS_CommAdmin Can you please get this changed in the documentation?
Thanks!
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!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: