<?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: How to stack macro variables into a column/dataset?! in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-stack-macro-variables-into-a-column-dataset/m-p/975011#M378013</link>
    <description>&lt;P&gt;I am not sure what you mean by "stack".&amp;nbsp; But it looks like you want to resolve a series of macro variables with the same base name and a numeric suffix.&amp;nbsp; Why not use SYMGET() function?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mvtemp；
  length var $32 ;
  var = symget(cats('var',_n_));
  input note $8.;
cards;
X
Xx
YYY
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or since it looks like the values of the VARxx macro variables have digit strings perhaps you want to use SYMGETN() instead?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mvtemp；
  value = symgetn(cats('var',_n_));
  input note $8.;
cards;
X
Xx
YYY
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 14 Sep 2025 14:48:29 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2025-09-14T14:48:29Z</dc:date>
    <item>
      <title>How to stack macro variables into a column/dataset?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-stack-macro-variables-into-a-column-dataset/m-p/974990#M377999</link>
      <description>I need stack a series into a dataset/column. Tried and failed. 
How to do it?




%let var1=205;  %let var3=306;  %let var3=409;

data mvtemp；
input var note  $8.;
datalines;
&amp;amp;var1.   X
&amp;amp;var2.   Xx
&amp;amp;var3.   YYY
;
run;quit;</description>
      <pubDate>Sun, 14 Sep 2025 02:34:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-stack-macro-variables-into-a-column-dataset/m-p/974990#M377999</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-09-14T02:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to stack macro variables into a column/dataset?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-stack-macro-variables-into-a-column-dataset/m-p/974991#M378000</link>
      <description>Here is a post, which is close.
&lt;A href="https://communities.sas.com/t5/SAS-Programming/Passing-a-Macro-Variable-value-into-a-data-step/m-p/791442#M253501" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Passing-a-Macro-Variable-value-into-a-data-step/m-p/791442#M253501&lt;/A&gt;

BUT I need use datalines to stack, rather than use = to assign.</description>
      <pubDate>Sun, 14 Sep 2025 02:35:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-stack-macro-variables-into-a-column-dataset/m-p/974991#M378000</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-09-14T02:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to stack macro variables into a column/dataset?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-stack-macro-variables-into-a-column-dataset/m-p/974996#M378001</link>
      <description>&lt;P&gt;Unfortunately, DATALINES or CARDS does not support macro variable ,you need put these macro variable into a text file ,and read this text file .&lt;/P&gt;
&lt;P&gt;This feature has already been mentioned in sas documentation.&lt;/P&gt;</description>
      <pubDate>Sun, 14 Sep 2025 06:27:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-stack-macro-variables-into-a-column-dataset/m-p/974996#M378001</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-09-14T06:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to stack macro variables into a column/dataset?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-stack-macro-variables-into-a-column-dataset/m-p/974998#M378003</link>
      <description>&lt;P&gt;But a workaround way is using RESOLVE() or SYMGETN().&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let var1=205; 
%let var2=306; 
%let var3=409; 

data mvtemp;
input var $ note $; 
new_var1=input(resolve(var),best.);
new_var2=symgetn(compress(var,'&amp;amp;.'));
datalines; 
&amp;amp;var1. X 
&amp;amp;var2. Xx 
&amp;amp;var3. YYY 
; 
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 14 Sep 2025 07:12:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-stack-macro-variables-into-a-column-dataset/m-p/974998#M378003</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-09-14T07:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to stack macro variables into a column/dataset?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-stack-macro-variables-into-a-column-dataset/m-p/974999#M378004</link>
      <description>&lt;P&gt;Thanks, It works.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I take from prev.&amp;nbsp; post. The code below is ok also.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mvars=&amp;amp;_ref_1.@&amp;amp;_ref_2.@&amp;amp;_ref_3.@&amp;amp;_ref_4.@&amp;amp;_ref_5.@&amp;amp;_ref_6.@&amp;amp;_ref_7.@&amp;amp;_ref_8.@&amp;amp;_ref_9.;
 %let mvars2=max@min@max@min@max@min@max@min@max;
	data &amp;amp;indexout._&amp;amp;dt._mm_ind;
	do i= 1 to countw(symget('mvars'),'@');
		length mm_indx note $8. ;
			mm_indx=scan(symget('mvars'),i,'@');
			note=scan(symget('mvars2'),i,'@');
		output;
	end;
	run;quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 14 Sep 2025 07:57:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-stack-macro-variables-into-a-column-dataset/m-p/974999#M378004</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-09-14T07:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to stack macro variables into a column/dataset?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-stack-macro-variables-into-a-column-dataset/m-p/975011#M378013</link>
      <description>&lt;P&gt;I am not sure what you mean by "stack".&amp;nbsp; But it looks like you want to resolve a series of macro variables with the same base name and a numeric suffix.&amp;nbsp; Why not use SYMGET() function?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mvtemp；
  length var $32 ;
  var = symget(cats('var',_n_));
  input note $8.;
cards;
X
Xx
YYY
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or since it looks like the values of the VARxx macro variables have digit strings perhaps you want to use SYMGETN() instead?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mvtemp；
  value = symgetn(cats('var',_n_));
  input note $8.;
cards;
X
Xx
YYY
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 14 Sep 2025 14:48:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-stack-macro-variables-into-a-column-dataset/m-p/975011#M378013</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-09-14T14:48:29Z</dc:date>
    </item>
  </channel>
</rss>

