DATA Step, Macro, Functions and more

dread

Accepted Solution Solved
Reply
Contributor
Posts: 23
Accepted Solution

dread

Hi dear,

 

Can someone please help me DREAD function from basic with clear example....


Accepted Solutions
Solution
‎11-16-2016 04:52 AM
Trusted Advisor
Posts: 1,129

Re: dread

Here is an article with examples which could be helpful, it also has dopen, dnum, dclose functions with examples

 

http://www.mwsug.org/proceedings/2012/S1/MWSUG-2012-S128.pdf

Thanks,
Jag

View solution in original post


All Replies
Solution
‎11-16-2016 04:52 AM
Trusted Advisor
Posts: 1,129

Re: dread

Here is an article with examples which could be helpful, it also has dopen, dnum, dclose functions with examples

 

http://www.mwsug.org/proceedings/2012/S1/MWSUG-2012-S128.pdf

Thanks,
Jag
Respected Advisor
Posts: 4,649

Re: dread

data files;
length file $128;
/* Define a filename pointing to the directory */
rc = filename("myDir", "C:\Users\PG\Documents\My SAS Files\9.4");
/* Open the directory, get directory id number */
dirId = dopen("myDir");
if dirId > 0 then do;
    /* dnum() : nb of files in directory */
    do i = 1 to dnum(dirId);
        /* Read the ith file name from directory */
        file = dread(dirId, i);
        if length(file) > 0 then output;
        end;
    /* Close the open directory */
    rc = dclose(dirId);
    end;
drop rc dirId i;
run;

proc print; run;
PG
☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 258 views
  • 0 likes
  • 3 in conversation