<?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 create and use macro variable within data step or any alternative? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-and-use-macro-variable-within-data-step-or-any/m-p/104006#M258355</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SAS variables get created during the compilation phase of a data step. It is not possible to create additional SAS variables during execution phase.&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#p08a4x7h9mkwqvn16jg3xqwfxful.htm" title="http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#p08a4x7h9mkwqvn16jg3xqwfxful.htm"&gt;SAS(R) 9.3 Language Reference: Concepts, Second Edition&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 07 Oct 2013 01:52:08 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2013-10-07T01:52:08Z</dc:date>
    <item>
      <title>how to create and use macro variable within data step or any alternative?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-and-use-macro-variable-within-data-step-or-any/m-p/104003#M258352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I was wondering if there is a way to write dataset variable into a macro variable and use the macro variable within the same datastep.&lt;BR /&gt;I have tried different approaches to do the following; but have been running into call symput, excute so far. Thanks for any help that might help to solve the situation...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data atmp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; input anID surfix $;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; datalines;&lt;BR /&gt;1 3_1&lt;BR /&gt;2 2_2&lt;BR /&gt;3 2_3&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data atmpdt;&lt;BR /&gt;input anID A_2_1 A_2_2 A_2_3 B_2_1 B_2_2 B_2_3;&lt;BR /&gt;datalines;&lt;BR /&gt;1 0.1 0.2 0.3 0.4 0.5 0.6&lt;BR /&gt;2 1.1 1.2 1.3 1.4 1.5 1.6&lt;BR /&gt;3 2.1 2.2 2.3 2.4 2.5 2.6&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let prefixlist=A B;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data atmp2;&lt;BR /&gt; Merge atmp atmpdt; by anID;&lt;BR /&gt; /*Intention: read current row variable surfix into the macro variable asurfix*/&lt;BR /&gt; call symput('Asurfix',surfix);&lt;/P&gt;&lt;P&gt; nbvar = countw("&amp;amp;prefixlist"," ");&lt;BR /&gt; /*Intention: for each name in the macro variable "prefixlist" &lt;BR /&gt; create a dataset set variable initiliazed with the value in the var &amp;amp;aprefix._&amp;amp;Asurfix&amp;nbsp; */&lt;BR /&gt;&amp;nbsp;&amp;nbsp; do count = 1 to nbvar;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput('aprefix',scan("&amp;amp;prefixlist",count," "));&lt;BR /&gt;&amp;nbsp; &amp;amp;aprefix=&amp;amp;aprefix._&amp;amp;Asurfix;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Oct 2013 18:44:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-and-use-macro-variable-within-data-step-or-any/m-p/104003#M258352</guid>
      <dc:creator>v</dc:creator>
      <dc:date>2013-10-04T18:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to create and use macro variable within data step or any alternative?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-and-use-macro-variable-within-data-step-or-any/m-p/104004#M258353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Look at SYMGET and RESOLVE functions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Oct 2013 18:54:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-and-use-macro-variable-within-data-step-or-any/m-p/104004#M258353</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-10-04T18:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to create and use macro variable within data step or any alternative?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-and-use-macro-variable-within-data-step-or-any/m-p/104005#M258354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To tell you the truth, I wouldn't do this with macros at all, I would use PROC TRANSPOSE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=atmpdt out=a;&lt;BR /&gt; by anID;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data aa;&lt;BR /&gt; merge a atmp;&lt;BR /&gt; by anID;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now you can assign A and B to the proper variables by matching text strings in data set AA, and throw out the observations in aa that don't match;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Oct 2013 18:58:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-and-use-macro-variable-within-data-step-or-any/m-p/104005#M258354</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2013-10-04T18:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: how to create and use macro variable within data step or any alternative?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-and-use-macro-variable-within-data-step-or-any/m-p/104006#M258355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SAS variables get created during the compilation phase of a data step. It is not possible to create additional SAS variables during execution phase.&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#p08a4x7h9mkwqvn16jg3xqwfxful.htm" title="http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#p08a4x7h9mkwqvn16jg3xqwfxful.htm"&gt;SAS(R) 9.3 Language Reference: Concepts, Second Edition&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Oct 2013 01:52:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-and-use-macro-variable-within-data-step-or-any/m-p/104006#M258355</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2013-10-07T01:52:08Z</dc:date>
    </item>
  </channel>
</rss>

