<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Thema "Re: Erzeuge Text/VariablenListe im Code mittels Macro - quasi C++ INLINE" in CoDe SAS German</title>
    <link>https://communities.sas.com/t5/CoDe-SAS-German/Erzeuge-Text-VariablenListe-im-Code-mittels-Macro-quasi-C-INLINE/m-p/243436#M1886</link>
    <description>&lt;P&gt;Für die Iteration braucht es den Makro-Compiler, weil das doch schon sehr high-level ist.&lt;/P&gt;
&lt;P&gt;Der C Preprocessor kennt zB gar keine Iterationen, nur simple if-Konditionen, die dort auch überall verwendet werden können.&lt;/P&gt;</description>
    <pubDate>Thu, 14 Jan 2016 09:56:56 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-01-14T09:56:56Z</dc:date>
    <item>
      <title>Erzeuge Text/VariablenListe im Code mittels Macro - quasi C++ INLINE</title>
      <link>https://communities.sas.com/t5/CoDe-SAS-German/Erzeuge-Text-VariablenListe-im-Code-mittels-Macro-quasi-C-INLINE/m-p/243418#M1880</link>
      <description>&lt;P&gt;Hallo zusammen,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ich würde gerne über ein Makro eine Liste von Variablen erzeugen, z.B. im Kontext einer Format-Anweisung oder&lt;/P&gt;
&lt;P&gt;auch für ein Array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Mein Ziel ist die Code-Zeile:&lt;/P&gt;
&lt;P&gt;AY(3) X2 X3 X4;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Diese Zeile soll dabei dynamisch über ein Macro erzeugt werden, ungefähr so:&lt;/P&gt;
&lt;P&gt;%let O = 4;&lt;/P&gt;
&lt;P&gt;%let U = 2;&lt;/P&gt;
&lt;P&gt;AY(%eval(&amp;amp;O-&amp;amp;U+1)) %do i=&amp;amp;U %to &amp;amp;O; X&amp;amp;i; %end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Leider klappt das aber so nicht.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Weiß hier jemand Rat?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Beste Grüße&lt;/P&gt;
&lt;P&gt;Wolfgang Müller&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 09:00:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/CoDe-SAS-German/Erzeuge-Text-VariablenListe-im-Code-mittels-Macro-quasi-C-INLINE/m-p/243418#M1880</guid>
      <dc:creator>wmueller</dc:creator>
      <dc:date>2016-01-14T09:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: Erzeuge Text/VariablenListe im Code mittels Macro - quasi C++ INLINE</title>
      <link>https://communities.sas.com/t5/CoDe-SAS-German/Erzeuge-Text-VariablenListe-im-Code-mittels-Macro-quasi-C-INLINE/m-p/243420#M1881</link>
      <description>&lt;P&gt;Hallo Herr Müller,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;das Semikolon bei X&amp;amp;i. ist an der falschen Stelle. Folgendermaßen geht es:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;a&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; U=2;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; O=4;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;data a;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;array AY(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%eval&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;O.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;-&amp;amp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;U.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;+&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;))&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; i = &amp;amp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;U.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;O.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; X&amp;amp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;i.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; a;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;a&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Viele Grüße&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Wolfgang Hornung&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 09:07:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/CoDe-SAS-German/Erzeuge-Text-VariablenListe-im-Code-mittels-Macro-quasi-C-INLINE/m-p/243420#M1881</guid>
      <dc:creator>WolfgangHornung</dc:creator>
      <dc:date>2016-01-14T09:07:36Z</dc:date>
    </item>
    <item>
      <title>Re: Erzeuge Text/VariablenListe im Code mittels Macro - quasi C++ INLINE</title>
      <link>https://communities.sas.com/t5/CoDe-SAS-German/Erzeuge-Text-VariablenListe-im-Code-mittels-Macro-quasi-C-INLINE/m-p/243421#M1882</link>
      <description>&lt;P&gt;In Erweiterung dessen, was Wofgang schon festgestellt hat:&lt;/P&gt;
&lt;P&gt;alles, was zwischen dem Semikolon am Ende des %do statements und dem %end steht, wird Teil des generierten Texts, also auch dort befindliche Semikolons. In den meisten Fällen macht man beim Arbeiten mit der SAS-Makrosprache zu viele Semikolons, die aber sehr oft nur leere Statements ohne syntaktische Probleme zur Folge haben.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 09:14:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/CoDe-SAS-German/Erzeuge-Text-VariablenListe-im-Code-mittels-Macro-quasi-C-INLINE/m-p/243421#M1882</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-01-14T09:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: Erzeuge Text/VariablenListe im Code mittels Macro - quasi C++ INLINE</title>
      <link>https://communities.sas.com/t5/CoDe-SAS-German/Erzeuge-Text-VariablenListe-im-Code-mittels-Macro-quasi-C-INLINE/m-p/243425#M1883</link>
      <description>&lt;P&gt;Hallo Herr Müller,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;hier bietet sich eine Makro-Funktion an, die als Rückgabewert einen String mit den erzeugten Variablennamen erhält. Hier ein kleines Beispiel:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Options mcompilenote=all;

%Macro varsList(prefix,start,end);
  %Local i varsList;
  %Do i=&amp;amp;start %To &amp;amp;end;
     %Let varsList = &amp;amp;varsList &amp;amp;prefix.&amp;amp;i;
  %End;
  &amp;amp;varsList
%Mend;

%Put NOTE: varsList(test,0,10): %varsList(test,0,10);

Data _null_;
  Retain %varsList(a,12,15) 0;
  Put (_all_)(=);
Run;

Data _Null_;
  Length %varsList(a,1,10) 8;
  Array aVars a:;
  Put aVars(*)=;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Der Parameter PREFIX entspricht dem eigentlichen Variablennamen, durch START und END wird die Numerierung festgelegt. Die Liste lässt sich dann in den unterschiedlichsten Kontexten verwenden, hier Beispiele für %PUT, Retain und Length Statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Viele Grüße,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Grischa Pfister&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 09:26:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/CoDe-SAS-German/Erzeuge-Text-VariablenListe-im-Code-mittels-Macro-quasi-C-INLINE/m-p/243425#M1883</guid>
      <dc:creator>GrischaPfister</dc:creator>
      <dc:date>2016-01-14T09:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: Erzeuge Text/VariablenListe im Code mittels Macro - quasi C++ INLINE</title>
      <link>https://communities.sas.com/t5/CoDe-SAS-German/Erzeuge-Text-VariablenListe-im-Code-mittels-Macro-quasi-C-INLINE/m-p/243431#M1884</link>
      <description>&lt;P&gt;Hallo zusammen,&lt;/P&gt;
&lt;P&gt;besten Dank für die schnelle kompetente Rückmeldung: es funktioniert!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Schade nur, dass man die Anweisung zuerst in ein "externes" Makro packen muss,&lt;/P&gt;
&lt;P&gt;dies macht den Code doch etwas unübersichtlich. Aber das lässt sich vermutlich nicht beheben&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: The %DO statement is not valid in open code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Beste Grüße&lt;/P&gt;
&lt;P&gt;Wolfgang Müller&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 09:44:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/CoDe-SAS-German/Erzeuge-Text-VariablenListe-im-Code-mittels-Macro-quasi-C-INLINE/m-p/243431#M1884</guid>
      <dc:creator>wmueller</dc:creator>
      <dc:date>2016-01-14T09:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: Erzeuge Text/VariablenListe im Code mittels Macro - quasi C++ INLINE</title>
      <link>https://communities.sas.com/t5/CoDe-SAS-German/Erzeuge-Text-VariablenListe-im-Code-mittels-Macro-quasi-C-INLINE/m-p/243436#M1886</link>
      <description>&lt;P&gt;Für die Iteration braucht es den Makro-Compiler, weil das doch schon sehr high-level ist.&lt;/P&gt;
&lt;P&gt;Der C Preprocessor kennt zB gar keine Iterationen, nur simple if-Konditionen, die dort auch überall verwendet werden können.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 09:56:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/CoDe-SAS-German/Erzeuge-Text-VariablenListe-im-Code-mittels-Macro-quasi-C-INLINE/m-p/243436#M1886</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-01-14T09:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: Erzeuge Text/VariablenListe im Code mittels Macro - quasi C++ INLINE</title>
      <link>https://communities.sas.com/t5/CoDe-SAS-German/Erzeuge-Text-VariablenListe-im-Code-mittels-Macro-quasi-C-INLINE/m-p/243438#M1888</link>
      <description>&lt;P&gt;Hallo, Herr Müller,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ich denke, in vielen Fällen geht es auch ohne Makro. Hier ein Beispiel mit ARRAY-Deklaration, RETAIN-, PUT- und KEEP-Statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let O=4;
%let U=2;

data test;
array ay x&amp;amp;U-x&amp;amp;O;
retain x&amp;amp;U-x&amp;amp;O 2016;
put (x&amp;amp;U-x&amp;amp;O)(=);
keep x&amp;amp;U-x&amp;amp;O; /* nur zur Demonstration */
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Da die Variablenliste doch durchgehend nummeriert sein soll, kann man die Variablenlistenschreibweise "Xm-Xn" verwenden, braucht also keine %DO-Schleife. In der Array-Deklaration ergibt sich die Dimension&amp;nbsp;des Arrays automatisch aus der Anzahl der Variablen in der Liste (hier: 3) und steht danach bei Bedarf auch als dim(ay) zur Verfügung.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 10:10:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/CoDe-SAS-German/Erzeuge-Text-VariablenListe-im-Code-mittels-Macro-quasi-C-INLINE/m-p/243438#M1888</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-01-14T10:10:06Z</dc:date>
    </item>
  </channel>
</rss>

