<?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 "Betreff: Makroprogrammierung mit Datastep" in CoDe SAS German</title>
    <link>https://communities.sas.com/t5/CoDe-SAS-German/Makroprogrammierung-mit-Datastep/m-p/547584#M2473</link>
    <description>durch das call execute muss das datenauszug warten,  bis data _null_ fertig ist.</description>
    <pubDate>Mon, 01 Apr 2019 10:14:04 GMT</pubDate>
    <dc:creator>JMS</dc:creator>
    <dc:date>2019-04-01T10:14:04Z</dc:date>
    <item>
      <title>Makroprogrammierung mit Datastep</title>
      <link>https://communities.sas.com/t5/CoDe-SAS-German/Makroprogrammierung-mit-Datastep/m-p/547583#M2472</link>
      <description>&lt;P&gt;hallo zusammen,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ich möchte in einem Makro ein Dataset anlegen und anschließend in Abhängigkeit der Anzahl Datensätze weitere Schritte unternehmen. Es gelingt mir nicht, die Makrovariable, die die Anzahl Datensätze beinhalten soll (anzobs) enthält immer denselben Wert.&lt;/P&gt;
&lt;P&gt;Irgendwie scheint der Datastep erst nach Durchlauf des Makros angelegt zu werden? Kann man das irgendwie anders lösen?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ich möchte gern, dass das Programm für alle IDs die Anzahl der selektierten Obs ausweist und für ID 1 und 2&amp;nbsp;"hallo" ausgibt:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dm 'cle log';
data daten;
   input id;
cards;
1
1
2
;
run;

data user;
   input id;
cards;
1
2
3
;
run;

%macro test(id=);

   data datenauszug;
      set daten(where=(id=&amp;amp;id));
   run;

   %let dsid    = %sysfunc(open(datenauszug));
   %let anzobs  = %sysfunc(attrn(&amp;amp;dsid, nlobs));
   %let rc      = %sysfunc(close(&amp;amp;dsid));
   %put &amp;amp;anzobs;

   %if &amp;amp;anzobs &amp;gt; 0 %then %do;
      %put 'hallo';
   %end;
%mend test;

data _null_;
   set user;
   call execute('%test(id='!!id!!')');
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hat einer eine Idee?&lt;/P&gt;
&lt;P&gt;vielen Dank!&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2019 10:02:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/CoDe-SAS-German/Makroprogrammierung-mit-Datastep/m-p/547583#M2472</guid>
      <dc:creator>HeideTribius</dc:creator>
      <dc:date>2019-04-01T10:02:51Z</dc:date>
    </item>
    <item>
      <title>Betreff: Makroprogrammierung mit Datastep</title>
      <link>https://communities.sas.com/t5/CoDe-SAS-German/Makroprogrammierung-mit-Datastep/m-p/547584#M2473</link>
      <description>durch das call execute muss das datenauszug warten,  bis data _null_ fertig ist.</description>
      <pubDate>Mon, 01 Apr 2019 10:14:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/CoDe-SAS-German/Makroprogrammierung-mit-Datastep/m-p/547584#M2473</guid>
      <dc:creator>JMS</dc:creator>
      <dc:date>2019-04-01T10:14:04Z</dc:date>
    </item>
    <item>
      <title>Betreff: Makroprogrammierung mit Datastep</title>
      <link>https://communities.sas.com/t5/CoDe-SAS-German/Makroprogrammierung-mit-Datastep/m-p/547585#M2474</link>
      <description>&lt;P&gt;Das ist das "klassische" Timing-Problem bei der Ausführung von Makros mit call execute. Die Makro-Anweisungen werden gleich an den Makroprozessor übergeben, data und proc steps müssen aber auf das Ende des momentan laufenden steps warten.&lt;/P&gt;
&lt;P&gt;Man muss den Makro zusätzlich maskieren:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call execute('%nrstr(%test(id='!!id!!'))');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Apr 2019 10:20:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/CoDe-SAS-German/Makroprogrammierung-mit-Datastep/m-p/547585#M2474</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-04-01T10:20:42Z</dc:date>
    </item>
    <item>
      <title>Betreff: Makroprogrammierung mit Datastep</title>
      <link>https://communities.sas.com/t5/CoDe-SAS-German/Makroprogrammierung-mit-Datastep/m-p/547589#M2475</link>
      <description>&lt;P&gt;Hallo Heide,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kurt hat Problem und Lösung schon beschrieben, wenn Du SAS 9.4 hast, kannst Du call execute() einfach durch rc = dosubl() ersetzen, dann werden Makro und data step ein einem zweiten Thread abgearbeitet und Du sieht das gewünschte Ergebnis.&lt;/P&gt;
&lt;P&gt;Denn zweiten Schritt mit open()/close() kannst Du Dir dann ebenfalls sparen, da die neue Makrovariable SYSNOBS nach Ausführen des Datastep die Anzahl der gefundenen Observations enthält.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test(id=);
   data datenauszug;
      set daten(where=(id=&amp;amp;id));
   run;
   %if &amp;amp;&amp;amp;sysnobs &amp;gt; 0 %then %do;
      %put 'hallo -&amp;gt; ' &amp;amp;sysnobs;
   %end;
%mend test;

data _null_;
   set user;
   rc=dosubl('%test(id='!!id!!')');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hoffe, das hilft weiter, viele Grüße,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Grischa&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2019 10:40:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/CoDe-SAS-German/Makroprogrammierung-mit-Datastep/m-p/547589#M2475</guid>
      <dc:creator>GrischaPfister</dc:creator>
      <dc:date>2019-04-01T10:40:35Z</dc:date>
    </item>
    <item>
      <title>Betreff: Makroprogrammierung mit Datastep</title>
      <link>https://communities.sas.com/t5/CoDe-SAS-German/Makroprogrammierung-mit-Datastep/m-p/547594#M2476</link>
      <description>&lt;P&gt;hallo Ihr zwei,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;herzlichen Dank! Es funktioniert hervorragend!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ich hätte Euch eher fragen sollen...&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2019 11:11:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/CoDe-SAS-German/Makroprogrammierung-mit-Datastep/m-p/547594#M2476</guid>
      <dc:creator>HeideTribius</dc:creator>
      <dc:date>2019-04-01T11:11:05Z</dc:date>
    </item>
    <item>
      <title>Betreff: Makroprogrammierung mit Datastep</title>
      <link>https://communities.sas.com/t5/CoDe-SAS-German/Makroprogrammierung-mit-Datastep/m-p/547596#M2477</link>
      <description>&lt;P&gt;Je nach Anwendung kannst du auch machen:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql; select id,count(id) from daten group by id; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;oder&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql; select id,count(id) into mid,mcount separated by ',' from daten group by id; run;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;mid;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;mcount;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2019 11:48:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/CoDe-SAS-German/Makroprogrammierung-mit-Datastep/m-p/547596#M2477</guid>
      <dc:creator>JMS</dc:creator>
      <dc:date>2019-04-01T11:48:32Z</dc:date>
    </item>
    <item>
      <title>Betreff: Makroprogrammierung mit Datastep</title>
      <link>https://communities.sas.com/t5/CoDe-SAS-German/Makroprogrammierung-mit-Datastep/m-p/547597#M2478</link>
      <description>&lt;P&gt;Ich hab's auch erst hier gelernt &lt;span class="lia-unicode-emoji" title=":zwinkerndes_Gesicht:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2019 12:08:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/CoDe-SAS-German/Makroprogrammierung-mit-Datastep/m-p/547597#M2478</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-04-01T12:08:15Z</dc:date>
    </item>
  </channel>
</rss>

