<?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 Create a table using values from macro variables in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-table-using-values-from-macro-variables/m-p/345215#M22843</link>
    <description>&lt;P&gt;Users define a couple of&amp;nbsp;macro variables (input):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let category = A B;
%let class = apple banana;
%let column = index character;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The generated table/dataset (output)&amp;nbsp;would look like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;category class index character
   A     apple   .       .
   A     banana  .       .
   B     apple   .       .
   B     banana  .       .&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;As you can see, for column 1 and column 2, they basically go through values of the macro variables, with macro variables' names as the column names. For column 3 and column 4, blanks, with macro variable's value as the column names (column 'index' has numeric values; column 'character' has char.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to achieve it?&lt;/P&gt;</description>
    <pubDate>Wed, 29 Mar 2017 01:16:49 GMT</pubDate>
    <dc:creator>ayin</dc:creator>
    <dc:date>2017-03-29T01:16:49Z</dc:date>
    <item>
      <title>Create a table using values from macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-table-using-values-from-macro-variables/m-p/345215#M22843</link>
      <description>&lt;P&gt;Users define a couple of&amp;nbsp;macro variables (input):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let category = A B;
%let class = apple banana;
%let column = index character;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The generated table/dataset (output)&amp;nbsp;would look like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;category class index character
   A     apple   .       .
   A     banana  .       .
   B     apple   .       .
   B     banana  .       .&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;As you can see, for column 1 and column 2, they basically go through values of the macro variables, with macro variables' names as the column names. For column 3 and column 4, blanks, with macro variable's value as the column names (column 'index' has numeric values; column 'character' has char.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to achieve it?&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2017 01:16:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-table-using-values-from-macro-variables/m-p/345215#M22843</guid>
      <dc:creator>ayin</dc:creator>
      <dc:date>2017-03-29T01:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: Create a table using values from macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-table-using-values-from-macro-variables/m-p/345268#M22851</link>
      <description>&lt;P&gt;Untested, so it's possible it needs a little debugging:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro generate (category=, class=, column=);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%local i j;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;length category class $ 8 &amp;amp;column 8;&lt;/P&gt;
&lt;P&gt;%do i=1 %to %sysfunc(countw(&amp;amp;category));&lt;/P&gt;
&lt;P&gt;%do j=1 %to %sysfunc(countw(&amp;amp;class));&lt;/P&gt;
&lt;P&gt;category = "%scan(&amp;amp;category, &amp;amp;i)";&lt;/P&gt;
&lt;P&gt;class = "%scan(&amp;amp;class, &amp;amp;j)";&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;%end;&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;%mend generate;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%generate (category=A B, class=apple banana, column=index character)&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2017 10:30:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-table-using-values-from-macro-variables/m-p/345268#M22851</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-03-29T10:30:05Z</dc:date>
    </item>
  </channel>
</rss>

