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

Hello Community,

Environment:

Enterprise Guide on UNIX via CITRIX over a Windows XP PC.

Situation:

I have serveral .CSV files located in /aaa/bbb/ccc/ddd

Now i would like to read all CSV files from this folder into a SAS table.

I only want to read the FILENAMES not the content.

I cant use "call system" or "filename x pile ..:" Statements. (Permissions)

I found another option by using the dopen() function.

When i try to open my file the dopenfunction returns a zero (file not found)

In the LOG  all files are accessed (see LOG)

Question:

I dont know what am I doing wrong? (im not having so much experience)

but why cant dopen open the directory and output my files.

Sourcecode

%let path = /aaa/bbb/ccc/ddd;

filename dir "&path/*";

data content;

    did=dopen("dir");

   if did eq 0 then do;

    infile dir length=linelen;

        input dir $Varying200. linelen;

   end;

   else do;

     msg=sysmsg();

      put msg;

   end;

run;

filename dir clear;

LOG:

NOTE: The infile DIR is:

      Filename=/aaa/bbb/ccc/ddd/2013-12-06-A.CSV,

      File List=/aaa/bbb/ccc/ddd/*,

    

NOTE: The infile DIR is:

      Filename=/aaa/bbb/ccc/ddd/2013-12-06-B.CSV,

      File List=/aaa/bbb/ccc/ddd/*,

 

NOTE: The infile DIR is:

      Filename=/aaa/bbb/ccc/ddd/2014-03-18-B.CSV,

      File List=/aaa/bbb/ccc/ddd/*,

 

NOTE: The infile DIR is:

      Filename=/aaa/bbb/ccc/ddd/2014-03-19-A.CSV,

      File List=/aaa/bbb/ccc/ddd/*,

    

WANT:

I want exactly this: 2013-12-06-A.CSV or the whole path /aaa/bbb/ccc/ddd/2014-03-19-A.CSV

in my table

can someone help me? I'm desperate...

Thanks

1 ACCEPTED SOLUTION
4 REPLIES 4
jakarman
Barite | Level 11

did you follow the example as of: SAS(R) 9.4 Functions and CALL Routines: Reference, Second Edition ?

It is the doptname function retrieving the information not the input statement.

What you have shown with the input statement is that a directory (with HFS as Unix/Windows)  is nothing more as a dataset. That dataset (directory) is having a list of pointers to ....

It is shamefull not having the OS layers for security in place as you can do everything with SAS. Oh they will try to block that also.

More easier would be allowing the x-cmd by you platform admin. When he did his work well putting you in an isolated secured box  sandbox. There is no security issue involved.

It is something like following the dogtail someone started it claiming it could be harmfull and without verifying understanding many followers. 

---->-- ja karman --<-----
jakarman
Barite | Level 11

Yes that is the one for the members with example

---->-- ja karman --<-----
asdf_sas
Calcite | Level 5

@Jaap Karmann

I totally agree with you...even  in a test envirnonment our permissions are restricted to nothing *laught

@Both

Thanks for the help it works Smiley Happy

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 4 replies
  • 5000 views
  • 7 likes
  • 3 in conversation