How to put a macro variable in character search

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 19
Accepted Solution

How to put a macro variable in character search

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


Accepted Solutions
Solution
‎09-18-2017 01:11 PM
PROC Star
Posts: 1,414

Re: How to put a macro variable in character search

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;

View solution in original post


All Replies
Solution
‎09-18-2017 01:11 PM
PROC Star
Posts: 1,414

Re: How to put a macro variable in character search

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;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 137 views
  • 1 like
  • 2 in conversation