<?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 SAS Macro in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Macro/m-p/26593#M6082</link>
    <description>Data x;&lt;BR /&gt;
input num;&lt;BR /&gt;
cards;&lt;BR /&gt;
1&lt;BR /&gt;
2&lt;BR /&gt;
3&lt;BR /&gt;
4&lt;BR /&gt;
;&lt;BR /&gt;
Run;&lt;BR /&gt;
&lt;BR /&gt;
I want the following output :&lt;BR /&gt;
&lt;BR /&gt;
%put =&amp;amp;y;&lt;BR /&gt;
&lt;BR /&gt;
OUTPUT:&lt;BR /&gt;
&lt;BR /&gt;
y=1,2,3,4 &lt;BR /&gt;
&lt;BR /&gt;
(Using ONLY with SAS Macro Statements)</description>
    <pubDate>Thu, 10 Mar 2011 14:47:40 GMT</pubDate>
    <dc:creator>SAS83</dc:creator>
    <dc:date>2011-03-10T14:47:40Z</dc:date>
    <item>
      <title>SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Macro/m-p/26593#M6082</link>
      <description>Data x;&lt;BR /&gt;
input num;&lt;BR /&gt;
cards;&lt;BR /&gt;
1&lt;BR /&gt;
2&lt;BR /&gt;
3&lt;BR /&gt;
4&lt;BR /&gt;
;&lt;BR /&gt;
Run;&lt;BR /&gt;
&lt;BR /&gt;
I want the following output :&lt;BR /&gt;
&lt;BR /&gt;
%put =&amp;amp;y;&lt;BR /&gt;
&lt;BR /&gt;
OUTPUT:&lt;BR /&gt;
&lt;BR /&gt;
y=1,2,3,4 &lt;BR /&gt;
&lt;BR /&gt;
(Using ONLY with SAS Macro Statements)</description>
      <pubDate>Thu, 10 Mar 2011 14:47:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Macro/m-p/26593#M6082</guid>
      <dc:creator>SAS83</dc:creator>
      <dc:date>2011-03-10T14:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Macro/m-p/26594#M6083</link>
      <description>Hello SAS83,&lt;BR /&gt;
&lt;BR /&gt;
What do you mean "Using ONLY with SAS Macro Statements"?&lt;BR /&gt;
&lt;BR /&gt;
The easiest and straitforward way to do it is this:&lt;BR /&gt;
[pre]proc SQL;&lt;BR /&gt;
  select num into :y separated ","  from x&lt;BR /&gt;
;quit;&lt;BR /&gt;
%put y=&amp;amp;y;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
"Using ONLY with SAS Macro Statements" approach results in &lt;BR /&gt;
[pre]%macro a;&lt;BR /&gt;
  proc SQL noprint;&lt;BR /&gt;
    select COUNT(*) into :n from x&lt;BR /&gt;
  ;quit;&lt;BR /&gt;
  proc transpose data=x out=t prefix=c;&lt;BR /&gt;
  run;&lt;BR /&gt;
  %do i=1 %to &amp;amp;n;&lt;BR /&gt;
    proc SQL noprint;&lt;BR /&gt;
      select c&amp;amp;i into :c&amp;amp;i from t&lt;BR /&gt;
    ;quit;&lt;BR /&gt;
  %end;&lt;BR /&gt;
  %let y=%TRIM(&amp;amp;c1),%TRIM(&amp;amp;c2),%TRIM(&amp;amp;c3),%TRIM(&amp;amp;c4);&lt;BR /&gt;
  %put y=&amp;amp;y;&lt;BR /&gt;
%mend;  &lt;BR /&gt;
%a[/pre]&lt;BR /&gt;
Is this what you need?&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Thu, 10 Mar 2011 15:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Macro/m-p/26594#M6083</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-03-10T15:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Macro/m-p/26595#M6084</link>
      <description>Perfect !! Thanks SPR.</description>
      <pubDate>Thu, 10 Mar 2011 17:16:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Macro/m-p/26595#M6084</guid>
      <dc:creator>SAS83</dc:creator>
      <dc:date>2011-03-10T17:16:26Z</dc:date>
    </item>
  </channel>
</rss>

