Macro rXDIR (from Fraktal SAS Programming)

Aus phenixxenia.org
Zur Navigation springen Zur Suche springen

Zurück

Übersicht

Vorwärts

What it does

This SAS Macro provides the function from XDIR in an interactive mode.

  • The recursive use of macro invocation keeps the macro "alive" until no further user input is made.
  • It might be of some interest to the novice user, how easy it is, to turn a simple "home-grew" function into an interactive tool.
Code executed Function performed

%MACRO rxdir(xpath);

Start macro definition with name and positional parameter xpath

%GLOBAL rpath;

Declare macrovariable rpath as global

%LET xpath = ;

Empty macrovariable xpath

%WINDOW path

Start definition for macro window path

irow = 20 rows = 14 icolumn = 130 columns = 64

Set coordinates for macro window path

#3 @5 "Current Path: &RPATH."

Define 1st output line containing value from macrovariable rpath

#5 @5 'Enter path: ' xpath 40 attr = blink

Define 2nd output line and field attributes to read macrovariable xpath

;

End definition of macro window path

%DISPLAY path;

Invoke macro window path

%IF %LENGTH(&XPATH.) = 0 %THEN %GOTO leave;

Branch for condition "null value entered"

%LET rpath = &RPATH.&XPATH.\;

Append value from macrovariable xpath to macrovariable rpath

filename path pipe "dir /b ""&RPATH.""" lrecl = 256;

Create file reference of type pipe to read entries from directory named in rpath

%PUT ---&RPATH.---;

Output roughly formatted header containing value from rpath

data _NULL_;

Initiate datastep w/o creating a dataset

length entry $256;

Specify field length to read directory entries' names into

infile path length = lrecl;

input entry $varying256. lrecl;

put entry;

run;

filename path clear;

%RXDIR(&RPATH.)

%LEAVE:

%LET rpath = ;

%MEND rxdir;

END macro definition with name

Zurück

Übersicht

Vorwärts