In this code bellow, I'm trying to put a varaiable for the letter A in the word ProfileA. I want to bea able to do it for ProfileB and ProfileC.
I've tried to put the variable &profile. to replace every "A" in the programme but it gives me empty table... No error in the log... So I figured that the problem was in the did=dopen("ProfileA") or in the findw(name,'ProfileA.csv') section... Hoe can I do to make it work?
Thank you!
%macro ouvrir(table,orni);
proc delete data=fichiers_profileA_&orni. fichiers_profileA;
run;quit;
data _null_;
set &table. end=eof;
if eof then call symput('nomdossier',_n_);
run;
%do i=1 %to &nomdossier;
data _null_;
set &table.(where=(numero=&i.));
%global dossier;
call symput('dossier',memname);
run;
%put &dossier;
/*****Faire la table avec tous les noms de fichiers*******/
%let rep=\\sdlc000-000010\soutien$\Projets\ORN - STL-0108\Acquisitions\&orni.\&dossier.;
filename profileA "&rep.";
data fichiers_profileA;
length name $55;
drop rc did i;
did=dopen("profileA");
if did > 0 then do;
do i=1 to dnum(did);
name=dread(did,i);
if findw(name,'ProfileA.csv')>0 then output;
end;
rc=dclose(did);
end;
else put 'Could not open directory';
run;
proc append data=fichiers_profileA base=fichiers_profileA_&orni.;
run;quit;
%end;
%mend ouvrir;
%ouvrir(Filenames1593_epuree,1593);
%ouvrir(Filenames4906_epuree,4906);
%ouvrir(Filenames6361_epuree,6361);
What do you get in the log? How many records are witten to fichiers_ProfileA?
I would add some PUT statments to help with debugging, e.g.:
data fichiers_profileA;
length name $55;
drop rc did i;
did=dopen("profileA");
put did= ;
if did > 0 then do;
do i=1 to dnum(did);
name=dread(did,i);
put i= name= ;
if findw(name,'ProfileA.csv')>0 then output;
end;
rc=dclose(did);
end;
else put 'Could not open directory';
run;
What do you get in the log? How many records are witten to fichiers_ProfileA?
I would add some PUT statments to help with debugging, e.g.:
data fichiers_profileA;
length name $55;
drop rc did i;
did=dopen("profileA");
put did= ;
if did > 0 then do;
do i=1 to dnum(did);
name=dread(did,i);
put i= name= ;
if findw(name,'ProfileA.csv')>0 then output;
end;
rc=dclose(did);
end;
else put 'Could not open directory';
run;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.