<?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 Storing the number of observations when using my Macro function? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Storing-the-number-of-observations-when-using-my-Macro-function/m-p/746977#M234405</link>
    <description>&lt;P&gt;I have created a macro called: num_obs that returns the number of observations in a data set.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I can save the result in an data step like:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;data saved_num_obs; 
	observ = %num_obs(WORK.TEST); 
run; &lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;Now, I would like to save the result to a macro variable instead.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;So, how would i save an result from using a macro to a Macro variable?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I thought something like:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let My_Macro = num_obs(test_table) ; 

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This does not work.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Any suggestions?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 10 Jun 2021 10:15:35 GMT</pubDate>
    <dc:creator>SasStatistics</dc:creator>
    <dc:date>2021-06-10T10:15:35Z</dc:date>
    <item>
      <title>Storing the number of observations when using my Macro function?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Storing-the-number-of-observations-when-using-my-Macro-function/m-p/746977#M234405</link>
      <description>&lt;P&gt;I have created a macro called: num_obs that returns the number of observations in a data set.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I can save the result in an data step like:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;data saved_num_obs; 
	observ = %num_obs(WORK.TEST); 
run; &lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;Now, I would like to save the result to a macro variable instead.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;So, how would i save an result from using a macro to a Macro variable?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I thought something like:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let My_Macro = num_obs(test_table) ; 

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This does not work.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Any suggestions?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 10:15:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Storing-the-number-of-observations-when-using-my-Macro-function/m-p/746977#M234405</guid>
      <dc:creator>SasStatistics</dc:creator>
      <dc:date>2021-06-10T10:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: Storing the number of observations when using my Macro function?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Storing-the-number-of-observations-when-using-my-Macro-function/m-p/746979#M234407</link>
      <description>&lt;P&gt;Just call the macro the same way you use in the data step: with leading %.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 10:33:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Storing-the-number-of-observations-when-using-my-Macro-function/m-p/746979#M234407</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-06-10T10:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: Storing the number of observations when using my Macro function?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Storing-the-number-of-observations-when-using-my-Macro-function/m-p/746992#M234417</link>
      <description>&lt;P&gt;If depends a lot on how the macro works.&lt;/P&gt;
&lt;P&gt;But first make sure to actually call the macro and not just assign the name of the macro to the macro variable.&amp;nbsp; You left the % out of your macro call.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let My_Macro = %num_obs(test_table) ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Jun 2021 11:52:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Storing-the-number-of-observations-when-using-my-Macro-function/m-p/746992#M234417</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-06-10T11:52:29Z</dc:date>
    </item>
  </channel>
</rss>

