<?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: Assigning macro a value of variable inside datastep in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Assigning-macro-a-value-of-variable-inside-datastep/m-p/397528#M96079</link>
    <description>Thank you for the prompt reply. I completely forget about the call symputx...</description>
    <pubDate>Wed, 20 Sep 2017 16:51:10 GMT</pubDate>
    <dc:creator>DmytroYermak</dc:creator>
    <dc:date>2017-09-20T16:51:10Z</dc:date>
    <item>
      <title>Assigning macro a value of variable inside datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assigning-macro-a-value-of-variable-inside-datastep/m-p/397521#M96076</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please help in the following case. I need to assign a value of substring to a macrovrariable. It should be done inside data step.&lt;/P&gt;&lt;P&gt;This program is not functioning. Y should be equal '3'. Could you please correct. Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
	EPOCH='TREATMENT 3';&lt;BR /&gt;
	%let TP=%sysfunc(substr(EPOCH,11,1));&lt;BR /&gt;
	Y="&amp;amp;TP.";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Sep 2017 16:38:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assigning-macro-a-value-of-variable-inside-datastep/m-p/397521#M96076</guid>
      <dc:creator>DmytroYermak</dc:creator>
      <dc:date>2017-09-20T16:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning macro a value of variable inside datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assigning-macro-a-value-of-variable-inside-datastep/m-p/397525#M96077</link>
      <description>&lt;P&gt;The correct functions to create a macro variable from a data step are Call Symput and Call sumputx.&lt;/P&gt;
&lt;P&gt;You generally would not be able to reference the macro variable created within the same data step (and why would it be needed).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt; EPOCH&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'TREATMENT 3'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;call symputx('TP',epoch);&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;%put &amp;amp;tp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;However if you use data step which uses a SET statement you will need to consider which record(s) you want to create the macro variable from as without conditional code it will create ONE macro variable with the LAST value from the data set read.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2017 16:47:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assigning-macro-a-value-of-variable-inside-datastep/m-p/397525#M96077</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-20T16:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning macro a value of variable inside datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assigning-macro-a-value-of-variable-inside-datastep/m-p/397528#M96079</link>
      <description>Thank you for the prompt reply. I completely forget about the call symputx...</description>
      <pubDate>Wed, 20 Sep 2017 16:51:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assigning-macro-a-value-of-variable-inside-datastep/m-p/397528#M96079</guid>
      <dc:creator>DmytroYermak</dc:creator>
      <dc:date>2017-09-20T16:51:10Z</dc:date>
    </item>
  </channel>
</rss>

