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;
BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: 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;
BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

sas-innovate-2024.png

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.

 

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.

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
  • 319 views
  • 1 like
  • 2 in conversation