<?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 assign specific value from table to macro variable based on value from another variable? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-specific-value-from-table-to-macro-variable-based/m-p/784331#M250287</link>
    <description>&lt;P&gt;You can create a macro variable using CALL SYMPUTX() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let percent=;
data _null_;
  set have;
  if status='Successfull" then call symputx('percent',percent');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to test whether the string in that macro variable is larger than some other floating point value make sure to use %SYSEVALF() as the normal %EVAL() macro function used in %IF will only handle integer arithmetic.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %sysevalf(&amp;amp;percent &amp;gt; 0.5 ) %then %do;
....
%end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 06 Dec 2021 15:49:05 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-12-06T15:49:05Z</dc:date>
    <item>
      <title>How to assign specific value from table to macro variable based on value from another variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-specific-value-from-table-to-macro-variable-based/m-p/784224#M250228</link>
      <description>&lt;P&gt;Hey guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my first post, just let me know if you need me to elaborate.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've created a proc freq table that I've outputted to a work file, and it looks like the below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Status&lt;/TD&gt;&lt;TD&gt;COUNT&lt;/TD&gt;&lt;TD&gt;PERCENT&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Successful&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;0.769231&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Unsuccessful&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;TD&gt;0.192308&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Unknown&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;0.038462&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to get the PERCENT value where the status was "Successful" and assign it to a macro variable that I can use at a later part of the programme.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know how I can do this? Thank you in advance for you help.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Dec 2021 23:43:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-specific-value-from-table-to-macro-variable-based/m-p/784224#M250228</guid>
      <dc:creator>wllm_fox</dc:creator>
      <dc:date>2021-12-05T23:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign specific value from table to macro variable based on value from another variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-specific-value-from-table-to-macro-variable-based/m-p/784324#M250284</link>
      <description>&lt;P&gt;I also asked on StackOverflow and a solution was provider there:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/70245993/sas-how-to-get-value-from-table-based-on-value-from-another-variable-and-assig" target="_blank"&gt;https://stackoverflow.com/questions/70245993/sas-how-to-get-value-from-table-based-on-value-from-another-variable-and-assig&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Dec 2021 15:07:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-specific-value-from-table-to-macro-variable-based/m-p/784324#M250284</guid>
      <dc:creator>wllm_fox</dc:creator>
      <dc:date>2021-12-06T15:07:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign specific value from table to macro variable based on value from another variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-specific-value-from-table-to-macro-variable-based/m-p/784331#M250287</link>
      <description>&lt;P&gt;You can create a macro variable using CALL SYMPUTX() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let percent=;
data _null_;
  set have;
  if status='Successfull" then call symputx('percent',percent');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to test whether the string in that macro variable is larger than some other floating point value make sure to use %SYSEVALF() as the normal %EVAL() macro function used in %IF will only handle integer arithmetic.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %sysevalf(&amp;amp;percent &amp;gt; 0.5 ) %then %do;
....
%end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Dec 2021 15:49:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-specific-value-from-table-to-macro-variable-based/m-p/784331#M250287</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-06T15:49:05Z</dc:date>
    </item>
  </channel>
</rss>

