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

Aus phenixxenia.org
Zur Navigation springen Zur Suche springen
(Die Seite wurde neu angelegt: „Kategorie:zazy {{SeitenNavigation1 |hoch=Duck_zazy_com.png |links=xx_left.png |rechts=xx_right.png |übersicht=Programming (from Fraktal SAS Programming) |…“)
 
K
Zeile 9: Zeile 9:
 
}}
 
}}
  
 +
== Positioning ==
 +
 +
Frankly, a '''''SAS Macro''''' is a code generator.
 +
 +
Even if '''''SAS''''' Macros are feeding their output directly into the '''''SAS''''' compiler, there is no need to restrict the code generated to '''''SAS''''' syntax. Instead, '''''SAS''''' syntax can be used to direct the code generated to any destination in reach, be it local files, portable media or some i-node on the internet. The same flexibility holds for local processes or ports on some IP-Address, but this will be discussed in detail elsewhere in these guidelines.
 +
 +
 +
== Programming ==
 +
 +
The authors did '''not design a new syntax''' to program the code generator, but used the '''same as they did for data processing''', which is, the data step language.
 +
 +
On the one hand, this is an '''advantage''', since it did not require another learning phase for the novice user, on the other hand this is a '''solid mess''' when macro code and data step language are mixed. The latter is possible and widely used by all levels of programmers.
 +
 +
Where datastep language does '''distinguish data types''' such as ''numeric'' and ''character'', the '''macro language does not'''. All values processed are character, which is, the code composed and finally output, i.e. sent to the '''''SAS''''' compiler.
 +
 +
 +
=== Hello World ===
 +
 +
The programmer's entry code gives an impression:
 +
 +
%MACRO first;
 +
%PUT Hello World;
 +
%MEND first;
 +
 +
To execute, issue the statement:
 +
 +
%FIRST;
 +
 +
 +
=== No Open Code ===
 +
 +
To achieve the same effect as in the example above, this code could also be used:
 +
 +
%PUT Hello World;
 +
 +
Such coding is called '''''OPEN CODE''''' and is possible for rapid prototyping in '''''SAS''''' when there's no logic, looping and branching required. This is not '''''SAS Macro Programming''''' as we want to use the term here.
 +
 +
Throughout these guidelines we will use '''the full range of ''Macro Coding''''' to program real '''''SAS'' Macros''', i.e. start each definition with a '''%MACRO''' statement and terminate it with a '''%MEND''' statement.
  
 
{{SeitenNavigation1
 
{{SeitenNavigation1

Version vom 16. Juli 2014, 15:24 Uhr

Zurück

Übersicht

Vorwärts

Positioning

Frankly, a SAS Macro is a code generator.

Even if SAS Macros are feeding their output directly into the SAS compiler, there is no need to restrict the code generated to SAS syntax. Instead, SAS syntax can be used to direct the code generated to any destination in reach, be it local files, portable media or some i-node on the internet. The same flexibility holds for local processes or ports on some IP-Address, but this will be discussed in detail elsewhere in these guidelines.


Programming

The authors did not design a new syntax to program the code generator, but used the same as they did for data processing, which is, the data step language.

On the one hand, this is an advantage, since it did not require another learning phase for the novice user, on the other hand this is a solid mess when macro code and data step language are mixed. The latter is possible and widely used by all levels of programmers.

Where datastep language does distinguish data types such as numeric and character, the macro language does not. All values processed are character, which is, the code composed and finally output, i.e. sent to the SAS compiler.


Hello World

The programmer's entry code gives an impression:

%MACRO first;
%PUT Hello World;
%MEND first;

To execute, issue the statement:

%FIRST;


No Open Code

To achieve the same effect as in the example above, this code could also be used:

%PUT Hello World;

Such coding is called OPEN CODE and is possible for rapid prototyping in SAS when there's no logic, looping and branching required. This is not SAS Macro Programming as we want to use the term here.

Throughout these guidelines we will use the full range of Macro Coding to program real SAS Macros, i.e. start each definition with a %MACRO statement and terminate it with a %MEND statement.

Zurück

Übersicht

Vorwärts