<?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>topic Re: writing a data step to put in macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/writing-a-data-step-to-put-in-macro-variable/m-p/316963#M69340</link>
    <description>&lt;P&gt;I would suggest a slightly different strategy. &amp;nbsp;Since you need a DATA step to create a macro variable, let the DATA step compute the average value as well. &amp;nbsp;Here is the idea:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;set have (keep=quantity) end=nomore;&lt;/P&gt;
&lt;P&gt;where quantity &amp;gt; .;&lt;/P&gt;
&lt;P&gt;tot_quantity + quantity;&lt;/P&gt;
&lt;P&gt;if nomore then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;* Divide TOT_QUANTITY by number of observations;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;* Transfer the result to a macro variable AVG;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The details are up to you.&lt;/P&gt;</description>
    <pubDate>Tue, 06 Dec 2016 09:24:51 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-12-06T09:24:51Z</dc:date>
    <item>
      <title>writing a data step to put in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/writing-a-data-step-to-put-in-macro-variable/m-p/316945#M69330</link>
      <description>&lt;P&gt;I have the following dataset: who's inputs are&amp;nbsp;CustomerID, SaleDate,Variety, Quantity&amp;nbsp;&lt;/P&gt;&lt;P&gt;240W 02-07-2008 Ginger 120&lt;BR /&gt;240W 02-07-2008 Protea 180&lt;BR /&gt;356W 02-08-2008 Heliconia 60&lt;BR /&gt;356W 02-08-2008 Anthurium 300&lt;BR /&gt;188R 02-11-2008 Ginger 24&lt;BR /&gt;188R 02-11-2008 Anthurium 24&lt;BR /&gt;240W 02-12-2008 Heliconia 48&lt;BR /&gt;240W 02-12-2008 Protea 48&lt;BR /&gt;356W 02-12-2008 Ginger 240&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I have to Write a procedure to compute the average quantity of sale. I then have to Write a DATA step to put the average quantity in a macro variable AVG, I cant use the %let statement. Run the program below.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; proc chart data = flowersales;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; vbar variety / type=mean sumvar=quantity ref=&amp;amp;avg; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I do this? I can't figure it out, please help me understand how it would work.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2016 06:54:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/writing-a-data-step-to-put-in-macro-variable/m-p/316945#M69330</guid>
      <dc:creator>nrb</dc:creator>
      <dc:date>2016-12-06T06:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: writing a data step to put in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/writing-a-data-step-to-put-in-macro-variable/m-p/316947#M69331</link>
      <description>&lt;P&gt;The steps are outlined.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First create the procedure to calculate the average - PROC MEANS&lt;/P&gt;
&lt;P&gt;Secomd, create a macro variable in a data step - CALL SYMPUTX()&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Given the phrasing here, I suspect this is a homework assignment so I won't write the code for you. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2016 06:58:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/writing-a-data-step-to-put-in-macro-variable/m-p/316947#M69331</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-12-06T06:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: writing a data step to put in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/writing-a-data-step-to-put-in-macro-variable/m-p/316958#M69337</link>
      <description>First write the data step to get average into a variable. This can be done by Proc SQL AVG function or by Proc Means. Then you use the two ways to ask SAS to automatically add this into Macro: &lt;BR /&gt;&lt;BR /&gt;By CallSymput routine&lt;BR /&gt;By Into: Statement in Proc SQL&lt;BR /&gt;&lt;BR /&gt;Both the methods are explained here with examples: &lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://analyticswithsas.blogspot.co.uk/2014/08/sas-macros-for-beginners.html?m=1" target="_blank"&gt;https://analyticswithsas.blogspot.co.uk/2014/08/sas-macros-for-beginners.html?m=1&lt;/A&gt;</description>
      <pubDate>Tue, 06 Dec 2016 08:56:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/writing-a-data-step-to-put-in-macro-variable/m-p/316958#M69337</guid>
      <dc:creator>sachin01663</dc:creator>
      <dc:date>2016-12-06T08:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: writing a data step to put in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/writing-a-data-step-to-put-in-macro-variable/m-p/316963#M69340</link>
      <description>&lt;P&gt;I would suggest a slightly different strategy. &amp;nbsp;Since you need a DATA step to create a macro variable, let the DATA step compute the average value as well. &amp;nbsp;Here is the idea:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;set have (keep=quantity) end=nomore;&lt;/P&gt;
&lt;P&gt;where quantity &amp;gt; .;&lt;/P&gt;
&lt;P&gt;tot_quantity + quantity;&lt;/P&gt;
&lt;P&gt;if nomore then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;* Divide TOT_QUANTITY by number of observations;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;* Transfer the result to a macro variable AVG;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The details are up to you.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2016 09:24:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/writing-a-data-step-to-put-in-macro-variable/m-p/316963#M69340</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-12-06T09:24:51Z</dc:date>
    </item>
  </channel>
</rss>

