<?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: Generate new (Macro)variable name according the existing variable NAME(Not value) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Generate-new-Macro-variable-name-according-the-existing-variable/m-p/149487#M29552</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Look into call symput and the vname function. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;VName will give the actual variable name for an array and call symput allows you to create a macro variable in a datastep dynamically. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Sep 2014 22:55:17 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2014-09-17T22:55:17Z</dc:date>
    <item>
      <title>Generate new (Macro)variable name according the existing variable NAME(Not value)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-new-Macro-variable-name-according-the-existing-variable/m-p/149484#M29549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now the issue is:&amp;nbsp; I have a series variable: V1, V2, ... Vn.&amp;nbsp; Each Variable has two value to classify the group: V1_a, V1_b. According to the variable value, Group information is assigned to another variable G1, G2, ... Gn.&amp;nbsp; For example: (V1 has value 1 to 10),&amp;nbsp; (V1_a=3, V1_b=7), then if&amp;nbsp; .Z&amp;lt;V1&amp;lt;=V1_a then G1=1, else if V1_a&amp;lt;V1&amp;lt;=V1_b then G1=2; else G1=3;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I have: Variable V1, V2, ... Vn.&amp;nbsp; and G1, G2, ... Gn.&amp;nbsp; Macro variables: V1_a, V1_b, V2_a, V2_b, ... Vn_a, Vn_b.&lt;/P&gt;&lt;P&gt;What I want to solve: I want to use a loop to automatically generate macro variable NAME - V1_a, V1_b, V2_a, V2_b, ... Vn_a, Vn_b, according to the Variable name: V1, V2, ... Vn.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In data step , how do I dynamic to generate macro variable name to generate the group variable?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA NEW;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET OLD;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ARRAY VAR_O{2, 50} V1, V2, ... V50 G1, G2, ... G50;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DO k = 1 TO 50;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*My problem to solve: Generate the macro name Vk_a, Vk_b*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF .Z &amp;lt; VAR_O{1, k} &amp;lt;= Vk_a THEN VAR{2, k}=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ELSE IF Vk_a &amp;lt;&amp;nbsp; VAR_O{1, k} &amp;lt;=&amp;nbsp; Vk_b THEN&amp;nbsp; VAR{2, k}=2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ELSE VAR{2, k}=3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions is appreciated.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Abdu.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2014 20:22:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-new-Macro-variable-name-according-the-existing-variable/m-p/149484#M29549</guid>
      <dc:creator>Abdu</dc:creator>
      <dc:date>2014-09-17T20:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: Generate new (Macro)variable name according the existing variable NAME(Not value)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-new-Macro-variable-name-according-the-existing-variable/m-p/149485#M29550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So you have macro variables, and you want to reference them inside the do loop.&lt;/P&gt;&lt;P&gt;symget() function does this.&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;IF .Z &amp;lt; VAR_O{1, k} &amp;lt;=input( symget('V'||strip( put(k,2.) )||'_a')&amp;nbsp; ,10.)&amp;nbsp; THEN VAR_O{2, k}=1;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;ELSE IF Vk_a &amp;lt;&amp;nbsp; VAR_O{1, k} &amp;lt;=&amp;nbsp; &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;input( symget('V'||strip( put(k,2.) )||'_b')&amp;nbsp; ,10.)&lt;/SPAN&gt; THEN&amp;nbsp; VAR_O{2, k}=2;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;ELSE VAR_O{2, k}=3;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Or maybe a better way is to define 2 temporary arrays that contain those macro variable values. Then you simply use arrays in the loop.&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;array V_A[50] _temporary_ (&amp;amp;V1_a &amp;amp;V2_a ... &amp;amp;V50_a);&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;array V_B[50] _temporary_ (&amp;amp;V1_b &amp;amp;V2_b ... &amp;amp;V50_b);&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;...&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;IF .Z &amp;lt; VAR_O{1, k} &amp;lt;= V_A&lt;K&gt; THEN VAR{2, k}=1;&lt;/K&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;ELSE IF Vk_a &amp;lt;&amp;nbsp; VAR_O{1, k} &amp;lt;=&amp;nbsp; V_B&lt;K&gt; THEN&amp;nbsp; VAR{2, k}=2;&lt;/K&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;ELSE VAR{2, k}=3;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2014 22:07:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-new-Macro-variable-name-according-the-existing-variable/m-p/149485#M29550</guid>
      <dc:creator>gergely_batho</dc:creator>
      <dc:date>2014-09-17T22:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: Generate new (Macro)variable name according the existing variable NAME(Not value)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-new-Macro-variable-name-according-the-existing-variable/m-p/149486#M29551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Greg,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your response.&amp;nbsp; Actually the Variables name V1, V2, ... Vk, is not a very tidy name, They are: Weight, Height, Volume,..., then the macro variable names are: (&amp;amp;Weight_3, &amp;amp;Weight_7), (&amp;amp;Height_3, &amp;amp;Height_7), (&amp;amp;Volume_3, &amp;amp;Volume_7) ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So your code does not work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyone has ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Abdu &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2014 22:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-new-Macro-variable-name-according-the-existing-variable/m-p/149486#M29551</guid>
      <dc:creator>Abdu</dc:creator>
      <dc:date>2014-09-17T22:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Generate new (Macro)variable name according the existing variable NAME(Not value)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-new-Macro-variable-name-according-the-existing-variable/m-p/149487#M29552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Look into call symput and the vname function. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;VName will give the actual variable name for an array and call symput allows you to create a macro variable in a datastep dynamically. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2014 22:55:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-new-Macro-variable-name-according-the-existing-variable/m-p/149487#M29552</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-09-17T22:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: Generate new (Macro)variable name according the existing variable NAME(Not value)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-new-Macro-variable-name-according-the-existing-variable/m-p/149488#M29553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't see any macro variables in your example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your description makes it sound like you want to convert a value into a bin numnber using a series of cut points.&lt;/P&gt;&lt;P&gt;That is if the cut points are 10,20,30,40 and the value is 15 then since it is between the the first and the second value you want to generate the number 2 (or 1 depending on if where you start counting).&amp;nbsp; &lt;/P&gt;&lt;P&gt;Where you want to store this generated number I cannot tell.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2014 23:31:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-new-Macro-variable-name-according-the-existing-variable/m-p/149488#M29553</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-09-17T23:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: Generate new (Macro)variable name according the existing variable NAME(Not value)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-new-Macro-variable-name-according-the-existing-variable/m-p/149489#M29554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, Reeza.&amp;nbsp; This problem bothered me many times, and I had to go around.&amp;nbsp; Now this is a short cut for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Abdu.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2014 23:34:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-new-Macro-variable-name-according-the-existing-variable/m-p/149489#M29554</guid>
      <dc:creator>Abdu</dc:creator>
      <dc:date>2014-09-17T23:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: Generate new (Macro)variable name according the existing variable NAME(Not value)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-new-Macro-variable-name-according-the-existing-variable/m-p/149490#M29555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Each variable have two cut points, which is saved in Macro variables.&amp;nbsp; The Macro variable name is correspondent to the variable name.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Abdu.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2014 23:37:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-new-Macro-variable-name-according-the-existing-variable/m-p/149490#M29555</guid>
      <dc:creator>Abdu</dc:creator>
      <dc:date>2014-09-17T23:37:43Z</dc:date>
    </item>
  </channel>
</rss>

