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;
The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.

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;
The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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