<?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 macro variable list elements in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-list-elements/m-p/732240#M228178</link>
    <description>&lt;P&gt;I would like to generate a new variable that is set equal to an element from a macro variable list. But, I want to select the element from the list based on a value in the dataset.&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let myvar = 12 23 95 1005;
data temp;
	do x = 1 to 4;
		output;
	end;
run;

data temp2;
	set temp;
	y=%scan(&amp;amp;myvar,x,' ');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This code yields an error because the %scan function is expecting an integer for the second condition.&lt;/P&gt;
&lt;P&gt;I want the output to be a dataset:&lt;BR /&gt;x&amp;nbsp;&amp;nbsp; y&lt;/P&gt;
&lt;P&gt;1&amp;nbsp;&amp;nbsp; 12&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;&amp;nbsp; 23&lt;/P&gt;
&lt;P&gt;3&amp;nbsp;&amp;nbsp; 95&lt;/P&gt;
&lt;P&gt;4&amp;nbsp;&amp;nbsp; 1005&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any thoughts or suggestions would be appreciated. Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Apr 2021 15:34:12 GMT</pubDate>
    <dc:creator>cminard</dc:creator>
    <dc:date>2021-04-08T15:34:12Z</dc:date>
    <item>
      <title>macro variable list elements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-list-elements/m-p/732240#M228178</link>
      <description>&lt;P&gt;I would like to generate a new variable that is set equal to an element from a macro variable list. But, I want to select the element from the list based on a value in the dataset.&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let myvar = 12 23 95 1005;
data temp;
	do x = 1 to 4;
		output;
	end;
run;

data temp2;
	set temp;
	y=%scan(&amp;amp;myvar,x,' ');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This code yields an error because the %scan function is expecting an integer for the second condition.&lt;/P&gt;
&lt;P&gt;I want the output to be a dataset:&lt;BR /&gt;x&amp;nbsp;&amp;nbsp; y&lt;/P&gt;
&lt;P&gt;1&amp;nbsp;&amp;nbsp; 12&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;&amp;nbsp; 23&lt;/P&gt;
&lt;P&gt;3&amp;nbsp;&amp;nbsp; 95&lt;/P&gt;
&lt;P&gt;4&amp;nbsp;&amp;nbsp; 1005&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any thoughts or suggestions would be appreciated. Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 15:34:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-list-elements/m-p/732240#M228178</guid>
      <dc:creator>cminard</dc:creator>
      <dc:date>2021-04-08T15:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable list elements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-list-elements/m-p/732248#M228181</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/27112"&gt;@cminard&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the SCAN function instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;y=scan("&amp;amp;myvar",x,' ');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or simply&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;y=scan("&amp;amp;myvar",x);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Apr 2021 16:00:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-list-elements/m-p/732248#M228181</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-04-08T16:00:04Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable list elements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-list-elements/m-p/732250#M228183</link>
      <description>&lt;P&gt;You need to use the SCAN() function in a data step. %SCAN() is for the macro processor, not for SAS code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp2;
	set temp;
	y=scan("&amp;amp;myvar",x,' ');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Apr 2021 16:00:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-list-elements/m-p/732250#M228183</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-08T16:00:27Z</dc:date>
    </item>
  </channel>
</rss>

