Macro XDIR (from Fraktal SAS Programming): Unterschied zwischen den Versionen

Aus phenixxenia.org
Zur Navigation springen Zur Suche springen
K
K
Zeile 17: Zeile 17:
 
|-
 
|-
 
|
 
|
 +
<font face="Courier New">
 
;%MACRO xdir(xpath);
 
;%MACRO xdir(xpath);
 +
</font>
 
|Start macro definition with name and positional parameter ''xpath''.
 
|Start macro definition with name and positional parameter ''xpath''.
 
|-
 
|-
 
|
 
|
 +
<font face="Courier New">
 
;%IF %LENGTH(&XPATH.) = 0 %THEN %DO;
 
;%IF %LENGTH(&XPATH.) = 0 %THEN %DO;
 +
</font>
 
|Define branch when parameter ''xpath'' is not supplied.
 
|Define branch when parameter ''xpath'' is not supplied.
 
|-
 
|-
 
|
 
|
 +
<font face="Courier New">
 
;%WINDOW path  
 
;%WINDOW path  
 +
</font>
 
|Start definition of pop-up window.
 
|Start definition of pop-up window.
 
|-
 
|-
 
|
 
|
 +
<font face="Courier New">
 
: irow = 20 rows = 14 icolumn = 30 columns = 64         
 
: irow = 20 rows = 14 icolumn = 30 columns = 64         
 +
</font>
 
|Specify position and size of window.
 
|Specify position and size of window.
 
|-
 
|-
 
|
 
|
 +
<font face="Courier New">
 
: #4 @5 'Enter path: ' xpath 40 attr = underline                 
 
: #4 @5 'Enter path: ' xpath 40 attr = underline                 
 +
</font>
 
|Specify constant text shown, parameter name to be populated and attributes.
 
|Specify constant text shown, parameter name to be populated and attributes.
 
|-
 
|-
 
|
 
|
 +
<font face="Courier New">
 
; ;
 
; ;
 +
</font>
 
|Terminate pop-up window definition statement.
 
|Terminate pop-up window definition statement.
 
|-
 
|-
 
|
 
|
 +
<font face="Courier New">
 
:%DISPLAY path;
 
:%DISPLAY path;
 +
</font>
 
|Open pop-up window.
 
|Open pop-up window.
 
|-
 
|-
 
|
 
|
 +
<font face="Courier New">
 
;%END;
 
;%END;
 +
</font>
 
|Finalize branch definition for empty parameter ''xpath''.
 
|Finalize branch definition for empty parameter ''xpath''.
 
|-
 
|-
 
|
 
|
 +
<font face="Courier New">
 
;filename path pipe "dir /b ""&XPATH.""" lrecl = 256;
 
;filename path pipe "dir /b ""&XPATH.""" lrecl = 256;
 +
</font>
 
|Define text data stream with type '''''pipe''''' and logical record length.
 
|Define text data stream with type '''''pipe''''' and logical record length.
 
|-
 
|-
 
|
 
|
 +
<font face="Courier New">
 
;data _NULL_;
 
;data _NULL_;
 +
</font>
 
|Initiate data step run group.
 
|Initiate data step run group.
 
|-
 
|-
 
|
 
|
 +
<font face="Courier New">
 
:length entry $256;
 
:length entry $256;
 +
</font>
 
|Specify length in byte for character field ''entry''.
 
|Specify length in byte for character field ''entry''.
 
|-
 
|-
 
|
 
|
 +
<font face="Courier New">
 
:infile path length = lrecl;
 
:infile path length = lrecl;
 +
</font>
 
|Open text data stream ''path''.
 
|Open text data stream ''path''.
 
|-
 
|-
 
|
 
|
 +
<font face="Courier New">
 
:input entry $varying256. lrecl;
 
:input entry $varying256. lrecl;
 +
</font>
 
|Specify structure of data stream ''path''.
 
|Specify structure of data stream ''path''.
 
|-
 
|-
 
|
 
|
 +
<font face="Courier New">
 
:  put entry;  
 
:  put entry;  
 +
</font>
 
|Write value from field ''entry'' to the SAS LOG screen.
 
|Write value from field ''entry'' to the SAS LOG screen.
 
|-
 
|-
 
|
 
|
 +
<font face="Courier New">
 
;run;
 
;run;
 +
</font>
 
|Terminate data step run group.
 
|Terminate data step run group.
 
|-
 
|-
 
|
 
|
 +
<font face="Courier New">
 
;filename path clear;
 
;filename path clear;
 +
</font>
 
|Revoke definition of text data stream.
 
|Revoke definition of text data stream.
 
|-
 
|-
 
|
 
|
 +
<font face="Courier New">
 
;%MEND xdir;
 
;%MEND xdir;
 +
</font>
 
|END macro definition with name
 
|END macro definition with name
 
|}
 
|}

Version vom 7. August 2014, 08:48 Uhr

Zurück

Übersicht

Vorwärts

This SAS Macro reads entries from a specified OS directory and writes results to the SAS LOG screen.

  • When no directory is specified, a pop-up window is defined and opened to ask the user for the directory name.
Code executed Function performed

%MACRO xdir(xpath);

Start macro definition with name and positional parameter xpath.

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

Define branch when parameter xpath is not supplied.

%WINDOW path

Start definition of pop-up window.

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

Specify position and size of window.

#4 @5 'Enter path: ' xpath 40 attr = underline

Specify constant text shown, parameter name to be populated and attributes.

 ;

Terminate pop-up window definition statement.

%DISPLAY path;

Open pop-up window.

%END;

Finalize branch definition for empty parameter xpath.

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

Define text data stream with type pipe and logical record length.

data _NULL_;

Initiate data step run group.

length entry $256;

Specify length in byte for character field entry.

infile path length = lrecl;

Open text data stream path.

input entry $varying256. lrecl;

Specify structure of data stream path.

put entry;

Write value from field entry to the SAS LOG screen.

run;

Terminate data step run group.

filename path clear;

Revoke definition of text data stream.

%MEND xdir;

END macro definition with name

Zurück

Übersicht

Vorwärts