BookmarkSubscribeRSS Feed
sassharp
Calcite | Level 5

Anybody have a designed macro like this ?

http://support.sas.com/kb/24/820.html

this one is in windows. But do need on UNIX

3 REPLIES 3
sassharp
Calcite | Level 5


At the bottom of that page is macro %dirlistwin this macro is for windows.

Do need macro to work on UNIX directory/file.

TomKari
Onyx | Level 15

I can get you started. Unfortunately, I don't have access to a Unix machine to check out the format of the directory listing.

1. Take a copy of the Windows version of the macro.

2. Change line

%if %upcase( &SUBDIR ) = Y %then %let SUBDIR = /s ; %else %let SUBDIR = ;

to

%if %upcase( &SUBDIR ) = Y %then %let SUBDIR = -R ; %else %let SUBDIR = ;

This changes the option correctly to ask for a subdirectory listing in Unix.

3. change line

filename DIRLIST pipe "dir /-c /q &SUBDIR /t:c ""&PATH""" ;

to

filename DIRLIST pipe "ls -l &SUBDIR ""&PATH""" ;

This will mostly change the Windows "dir" command to the Unix "ls" command, which is the equivalent. I'm not sure if the quote structure around the directory name will work the same...you'll need to test that.

4. This should get you down to the section of code beginning with

      input line $varying1024. reclen ;

which is the statement that reads the directory info. I suggest you just comment out the rest of this step for now, which should result in one record, with a variable "line", for every line of your directory result. You can then use this example to recode the rest of the step to accomodate the different Unix format.

Good luck!

  Tom

Tom
Super User Tom
Super User

You can get the filename without using operating system commands.  Look at code posted by LINLIN on this thread for one example.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 971 views
  • 0 likes
  • 3 in conversation