Anweisungen mehrzeilig
Wenn eine Anweisung mehr als zwei Objekte (Variablennamen, Dateinamen, Makroparameter etc.) enthält, wird jedes Objekt auf eine neue Zeile geschrieben und die Anweisung wird so formatiert, dass man ohne weiteres neue Objekte hinzufügen oder vorhandene löschen kann, ohne die Anweisung insgesamt zu verändern. Das bedeutet auch, dass man das schließende Semikolon auf eine eigene Zeile schreibt und dass man in durch Kommata getrennten Listen die Kommata jeweils an den Beginn jeder Zeile statt an das Ende schreibt.
Begründung: Dadurch wird es einfacher, bestehenden Code zu überarbeiten, insbesondere, weitere Variablen hinzuzunehmen oder auch Variablen von einer Anweisung in eine andere zu kopieren. Auch kann man einfacher eines oder mehrere Objekte innerhalb einer Anweisung durch /* */ auskommentieren.
Beispiel im DATA-Schritt
length
land $ 30
stadt $ 30
xkoord 8
ykoord 8
;
label
land = 'Bundesland'
stadt = 'Hauptstadt'
xkoord = 'X-Koordinate'
ykoord = 'Y-Koordinate'
;
format
xkoord ykoord time8.
;
informat
xkoord ykoord time.
;
input
land
stadt
xkoord
ykoord
;
datalines;
Hessen Frankfurt 8:41 50:07
Bayern München 11:35 48:09
;
mit ATTRIB wird es noch übersichtlicher
attrib
land length=$30 label='Bundesland'
stadt length=$30 label='Hauptstadt'
xkoord length=8 label='X-Koordinate' format=time8. informat=time.
ykoord length=8 label='Y-Koordinate' format=time8. informat=time.
;
input
land
stadt
xkoord
ykoord
;
datalines;
Hessen Frankfurt 8:41 50:07
Bayern München 11:35 48:09
;
Beispiel für SQL
select
bestellung.id
,produkt.id
,produkt.name
,bestellung.anzahl * produkt.preis as gesamtpreis format=commax10.2
from
order
,produkt
where
bestellung.produktid = produkt.id
;
quit;
Beispiel für Makro-Aufruf:
, VKORG=1030
, VTWEG= /* alle VTWEGe */
, MM_Info=no
, JJ_Info=no
, MManz = JA /* der TABULATE ist ... */
, atag_von= /* leer=default */
/*, atag_bis=20060228 */
, atag_bis= /* leer=default=keine */
, kumvar=auft /* Kumulierung auf Auft */
, scorvar=CEG /* leer=autom. CEG-Scorewerte*/
/*, tstinlib=dmworkOI */
);
so sollte man es dagegen nicht machen
length land $30 stadt $30 xkoord 8 ykoord 8;
label land='Bundesland' stadt='Hauptstadt' xkoord='X-Koordinate' ykoord='Y-Koordinate';
format xkoord ykoord time8.;
informat xkoord ykoord time.;
input land stadt xkoord ykoord;
datalines;
Hessen Frankfurt 8:41 50:07
Bayern München 11:35 48:09
;
und so auch nicht
select bestellung.id, produkt.id, produkt.name, bestellung.anzahl * produkt.preis as gesamtpreis format=commax10.2
from order, produkt
where bestellung.produktid = produkt.id;
quit;
