Generalized Approach (from Fraktal SAS Programming)

Version vom 30. Januar 2014, 10:31 Uhr von Wolf-Dieter Batz (Diskussion | Beiträge)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Zur Navigation springen Zur Suche springen




It appears necessary to stress here, that any MACRO does not execute the program code contained but passes it to the SAS compiler which will perform a Compile-and-Go step as default. Nevertheless it would be premature to assume that this mechanism requires the code to be SAS code.

Instead, it is possible to GENERATE-and-PASS any code.

SAS provides means and concepts to direct generated source code to appropriate agents, be it external programs or the operating system itself. OS functions may be called explicitly or implicitly or code may be written to a text file that is executed later on.

Out of the numerous options, the following two might appear quite useful.

Utilize OS Functions

1. Access results from OS commands as data source.

filename myfref  pipe “dir c:\ /d”;

This statement assigns a file reference with target type pipe. The pipe type dynamically accesses the result of an OS function as data stream that can be used as text input file inside a data step.

2. Perform an operation on OS level.

systask command “mkdir c:\&MYDIR.”;

The SYSTASK statement is a powerful means to initiate and control background tasks. With options WAIT/NOWAIT it provides direct utilization of OS multitasking by initiating parts of complex SAS code as background tasks.

Write Vector Graphics

filename _xml_ "&MYPTH.\&MYGPH..svg";
data _null_;
file _xml_;
put '<?xml version="1.0" standalone="no"?>';
put '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "">';
put '<svg xmlns="" version="1.1" 
 width="29.7cm" height="21cm" 
 viewBox="-200 -100 1200 800"> 
 <desc> Example anim01 - demonstrate animation elements 
 <title> SpotGrid 
put '
 <rect id="OuterBorder" x="-4" y="-4" width="904" height="604" fill="rgb(255,255,255)" stroke="rgb(0,0,0)" stroke-width="8">  
put '</svg>';