Help using Base SAS procedures

Importing filenames w/o use of a pipe

Accepted Solution Solved
Reply
Frequent Contributor
Frequent Contributor
Posts: 133
Accepted Solution

Importing filenames w/o use of a pipe

Hello all-

I am well acquainted the use of pipes-

However is there an alt method of importing filenames?

I ask due to the fact that at some point I will have to port a program to EG.

Yes I know that I can change the registry however I don't have such permissions and even if I do-I may not have the permissions on the server.

Thanks.

Lawrence


Accepted Solutions
Solution
‎04-25-2012 07:51 AM
Frequent Contributor
Posts: 101

Re: Importing filenames w/o use of a pipe

To build on data_null_'s reply, here's something to get you started.

data _null_;

rc = filename( 'mydir', 'c:\temp' );

did = dopen( 'mydir' );

count = dnum( did );

do i = 1 to count;

   filenm = dread( did, i );

   putlog filenm;

end;

run;

Note that the dread function returns not only file names but directories too. You'll have to account for that.

View solution in original post


All Replies
Respected Advisor
Posts: 3,777

Re: Importing filenames w/o use of a pipe

See function category External Files

Solution
‎04-25-2012 07:51 AM
Frequent Contributor
Posts: 101

Re: Importing filenames w/o use of a pipe

To build on data_null_'s reply, here's something to get you started.

data _null_;

rc = filename( 'mydir', 'c:\temp' );

did = dopen( 'mydir' );

count = dnum( did );

do i = 1 to count;

   filenm = dread( did, i );

   putlog filenm;

end;

run;

Note that the dread function returns not only file names but directories too. You'll have to account for that.

Respected Advisor
Posts: 3,895

Re: Importing filenames w/o use of a pipe

Allowing shell escape (xcmd) is a simple tick in a box using SMC. The tick-box is "hidden" in the Workspace Server Properties under "Options/Advanced Options".

So it's a SAS Metadata change and not some client sided change of registry information.

Else: What data _null_; suggests. I recall several discussions and solutions around this question here in these forums. Searching with keywords "directory list" will bring up some of them.

May be this sample code will help: http://support.sas.com/kb/25/074.html

Frequent Contributor
Frequent Contributor
Posts: 133

Re: Importing filenames w/o use of a pipe

Thanks all!

Esp SAS Bigot-Answer helped immensely.

Lawrence

☑ This topic is SOLVED.

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

Discussion stats
  • 4 replies
  • 298 views
  • 4 likes
  • 4 in conversation