<?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: storing macro variable values  in data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/storing-macro-variable-values-in-data-set/m-p/260513#M50560</link>
    <description>@ LinusH. This is just an example. But I know being able to process list (either horizontal or vertical) is an important skill.</description>
    <pubDate>Thu, 31 Mar 2016 18:52:54 GMT</pubDate>
    <dc:creator>SAS_inquisitive</dc:creator>
    <dc:date>2016-03-31T18:52:54Z</dc:date>
    <item>
      <title>storing macro variable values  in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/storing-macro-variable-values-in-data-set/m-p/260471#M50547</link>
      <description>&lt;P&gt;I want to store values of macro variable "&amp;amp;macvar" in a data set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro m;

	proc sql noprint;
		select distinct name
			into: macvar separated by ' '
		from sashelp.class;
	quit;

	%put &amp;amp;macvar;

	data _null_;
		%do i= 1 %to 19;
			%put %scan(&amp;amp;macvar,&amp;amp;i,' ');
		%end;
	run;

%mend m;

%m&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Mar 2016 17:02:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/storing-macro-variable-values-in-data-set/m-p/260471#M50547</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-03-31T17:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: storing macro variable values  in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/storing-macro-variable-values-in-data-set/m-p/260479#M50548</link>
      <description>&lt;P&gt;If you want the individual NAME values stored separately, you don't need the macro variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table want as select distinct name from sashelp.class;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want the entire string stored as one long DATA step variable, you could use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;value = "&amp;amp;macvar";&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2016 17:32:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/storing-macro-variable-values-in-data-set/m-p/260479#M50548</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-03-31T17:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: storing macro variable values  in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/storing-macro-variable-values-in-data-set/m-p/260484#M50549</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;. I was trying to process the list (&amp;amp;macvar) and output each value in a data set (such as using &amp;nbsp;OUTPUT statement).&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2016 17:47:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/storing-macro-variable-values-in-data-set/m-p/260484#M50549</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-03-31T17:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: storing macro variable values  in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/storing-macro-variable-values-in-data-set/m-p/260487#M50550</link>
      <description>&lt;P&gt;OK, still not too difficult.&amp;nbsp; Here's the basic idea:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;length value $ 32;&lt;/P&gt;
&lt;P&gt;do i=1 to countw("&amp;amp;macvar");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; value = scan("&amp;amp;macvar", i, ' ');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&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;I'm not sure if there might be a set of special characters that COUNTW would treat as delimiters (besides a blank).&amp;nbsp; You might have to modify the DO statement to account for that, if &amp;amp;MACVAR might contain special characters.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2016 17:59:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/storing-macro-variable-values-in-data-set/m-p/260487#M50550</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-03-31T17:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: storing macro variable values  in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/storing-macro-variable-values-in-data-set/m-p/260489#M50551</link>
      <description>Assuming that this for learning purpose only since the operation of creating a  macro variable from a table, and then create a new table with its values is just crazy.&lt;BR /&gt;Or is there a real requirement that is not shown by your example? &lt;BR /&gt;As stated, can't recall any real world case where I did such an operation. &lt;BR /&gt;But technically, you need to scan the the variable in a do while/until loop and do explicit output.</description>
      <pubDate>Thu, 31 Mar 2016 18:02:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/storing-macro-variable-values-in-data-set/m-p/260489#M50551</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-03-31T18:02:55Z</dc:date>
    </item>
    <item>
      <title>Re: storing macro variable values  in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/storing-macro-variable-values-in-data-set/m-p/260509#M50559</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;. &amp;nbsp;Thank you. This is what I was looking for.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2016 18:42:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/storing-macro-variable-values-in-data-set/m-p/260509#M50559</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-03-31T18:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: storing macro variable values  in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/storing-macro-variable-values-in-data-set/m-p/260513#M50560</link>
      <description>@ LinusH. This is just an example. But I know being able to process list (either horizontal or vertical) is an important skill.</description>
      <pubDate>Thu, 31 Mar 2016 18:52:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/storing-macro-variable-values-in-data-set/m-p/260513#M50560</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-03-31T18:52:54Z</dc:date>
    </item>
  </channel>
</rss>

