<?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 How to assign Macro Variable Depends on Another MVar Value?! in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-Macro-Variable-Depends-on-Another-MVar-Value/m-p/977553#M378502</link>
    <description>&lt;P&gt;I know how to assign MVar like below.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let ref_mm_ind=100; %let ref_mm_ind_stind=%sysfunc(max(10,%eval(&amp;amp;ref_mm_ind.-150*4)));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now I have another macro variable, mmnote, which can be max or min.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I need if mmnote=max, assign 400 to&amp;nbsp;&lt;CODE class=" language-sas"&gt;ref_mm_ind_stind;&amp;nbsp;if&amp;nbsp;mmnote=min,&amp;nbsp;keep&amp;nbsp;untouch&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;as&amp;nbsp;above.&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;How&amp;nbsp;to&amp;nbsp;do&amp;nbsp;with&amp;nbsp;just&amp;nbsp;%let&amp;nbsp;lines?!&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;Thanks,&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Oct 2025 07:06:31 GMT</pubDate>
    <dc:creator>hellohere</dc:creator>
    <dc:date>2025-10-22T07:06:31Z</dc:date>
    <item>
      <title>How to assign Macro Variable Depends on Another MVar Value?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-Macro-Variable-Depends-on-Another-MVar-Value/m-p/977553#M378502</link>
      <description>&lt;P&gt;I know how to assign MVar like below.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let ref_mm_ind=100; %let ref_mm_ind_stind=%sysfunc(max(10,%eval(&amp;amp;ref_mm_ind.-150*4)));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now I have another macro variable, mmnote, which can be max or min.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I need if mmnote=max, assign 400 to&amp;nbsp;&lt;CODE class=" language-sas"&gt;ref_mm_ind_stind;&amp;nbsp;if&amp;nbsp;mmnote=min,&amp;nbsp;keep&amp;nbsp;untouch&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;as&amp;nbsp;above.&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;How&amp;nbsp;to&amp;nbsp;do&amp;nbsp;with&amp;nbsp;just&amp;nbsp;%let&amp;nbsp;lines?!&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;Thanks,&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Oct 2025 07:06:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-Macro-Variable-Depends-on-Another-MVar-Value/m-p/977553#M378502</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-10-22T07:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign Macro Variable Depends on Another MVar Value?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-Macro-Variable-Depends-on-Another-MVar-Value/m-p/977557#M378503</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/409584"&gt;@hellohere&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n0l3n5z2h31h7wn1fmnqd33ibhap.htm" target="_blank" rel="noopener"&gt;IFN&lt;/A&gt; and &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p07za51a2k0sxkn1m0tulx2cy464.htm" target="_blank" rel="noopener"&gt;IFC&lt;/A&gt; functions in conjunction with %SYSFUNC to assign a value conditionally:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let ref_mm_ind_stind=%sysfunc(ifn(&amp;amp;mmnote=max, 400, &amp;amp;ref_mm_ind_stind));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Oct 2025 07:31:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-Macro-Variable-Depends-on-Another-MVar-Value/m-p/977557#M378503</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-10-22T07:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign Macro Variable Depends on Another MVar Value?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-Macro-Variable-Depends-on-Another-MVar-Value/m-p/977559#M378504</link>
      <description>Thanks,</description>
      <pubDate>Wed, 22 Oct 2025 07:39:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-Macro-Variable-Depends-on-Another-MVar-Value/m-p/977559#M378504</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-10-22T07:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign Macro Variable Depends on Another MVar Value?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-Macro-Variable-Depends-on-Another-MVar-Value/m-p/977644#M378518</link>
      <description>&lt;P&gt;Related functions WHICHN and WHICHC may be useful if you need to extend this logic to selecting more&amp;nbsp; choices.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Be very sure of the CASE of the compared character values using IFC and WHICHC.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let ref_mm_ind_stind=%sysfunc(ifn(&amp;amp;mmnote=max, 400, &amp;amp;ref_mm_ind_stind)); would not get the desired behavior if &amp;amp;mmnote has a value of MAX (or many others with one or more capital letters). If the resolved values of the macro variable MMNOTE might have case issues then use one of the %LOWCASE or %UPCASE in macro code such as&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;%let ref_mm_ind_stind=%sysfunc(ifn(%lowcase(&amp;amp;mmnote)=max, 400, &amp;amp;ref_mm_ind_stind));&lt;/LI-CODE&gt;
&lt;P&gt;This can be very important if you have to deal with user entered values such as a response to a prompt.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Oct 2025 05:30:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-Macro-Variable-Depends-on-Another-MVar-Value/m-p/977644#M378518</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2025-10-23T05:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign Macro Variable Depends on Another MVar Value?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-Macro-Variable-Depends-on-Another-MVar-Value/m-p/977652#M378519</link>
      <description>&lt;P&gt;Note sure why you think it makes sense to limit to "just %let lines".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So assuming that&amp;nbsp;&lt;SPAN&gt;mmnote is also a macro variable then to test if its value is min you would add a simple %IF/%THEN/%DO block.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mmnote=max;
%let ref_mm_ind=100;
%if &amp;amp;mmnote=max %then %do;
  %let ref_mm_ind_stind=400;
%end;
%else %do;
  %let ref_mm_ind_stind=%sysfunc(max(10,%eval(&amp;amp;ref_mm_ind.-150*4)));
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;So no need to build complex nested function calls that will be difficult to maintain.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also do you really want to calculate the formula (&amp;amp;ref_mm_ind - 150*4) using the INTEGER ONLY arithmetic that the macro function %EVAL() uses?&amp;nbsp; That will only work if REF_MM_IND only includes digits.&amp;nbsp; If you remove the %EVAL() then the formula will be passed to SAS itself to handle so that normal arithmetic will be used instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Oct 2025 13:17:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-Macro-Variable-Depends-on-Another-MVar-Value/m-p/977652#M378519</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-10-23T13:17:03Z</dc:date>
    </item>
  </channel>
</rss>

