BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bemariec
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

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

1 REPLY 1
Quentin
Super User

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;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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