<?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: is there a way to use the lookupvalue function to put the selected value in a macro variable in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/is-there-a-way-to-use-the-lookupvalue-function-to-put-the/m-p/860660#M42374</link>
    <description>This code will be useful too.  Thank you very much</description>
    <pubDate>Fri, 24 Feb 2023 13:15:42 GMT</pubDate>
    <dc:creator>alepage</dc:creator>
    <dc:date>2023-02-24T13:15:42Z</dc:date>
    <item>
      <title>is there a way to use the lookupvalue function to put the selected value in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/is-there-a-way-to-use-the-lookupvalue-function-to-put-the/m-p/860573#M42360</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I just saw on the web the lookupvalue function.&amp;nbsp; Is there a way to provide a company name and to put the corresponding codeid into a macro variable ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What's the best way to do that ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DirInfo1;
   input codeid $ name $ ;
   datalines;
1A2345 IA
1B2354 Promutuel
1C2366 Desjardins
1D2378 TD
run;
data _null_;
if name eq IA then %let codeid=lookupvalue('DirInfo1', IA)
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Feb 2023 21:50:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/is-there-a-way-to-use-the-lookupvalue-function-to-put-the/m-p/860573#M42360</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2023-02-23T21:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: is there a way to use the lookupvalue function to put the selected value in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/is-there-a-way-to-use-the-lookupvalue-function-to-put-the/m-p/860575#M42361</link>
      <description>&lt;P&gt;I've never seen the LookUpValue() function.&amp;nbsp; Looks like that is a SAS Intelligent Decisioning thing.&amp;nbsp; Are you using that product?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you familiar with using SAS formats for lookups?&amp;nbsp; That would be the usual BASE SAS approach.&amp;nbsp; And you could use the format to generate a macro variable with the company name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 21:57:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/is-there-a-way-to-use-the-lookupvalue-function-to-put-the/m-p/860575#M42361</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-02-23T21:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: is there a way to use the lookupvalue function to put the selected value in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/is-there-a-way-to-use-the-lookupvalue-function-to-put-the/m-p/860577#M42362</link>
      <description>&lt;P&gt;Your code is not valid in several senses.&lt;/P&gt;
&lt;P&gt;Macro statements like %LET are executed while code is fetched, before the DATA step is even compiled. Since then the macro code resolves to nothing for the data step compiler, it gets this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
if name eq IA then&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(because of a missing semicolon, the run becomes part of the %LET)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to create macro variables from data step values, you must use CALL SYMPUT or CALL SYMPUTX.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A search for lookupvalue on documentation.sas.com gets zero results, so where did you find that (provide a link)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 22:18:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/is-there-a-way-to-use-the-lookupvalue-function-to-put-the/m-p/860577#M42362</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-23T22:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: is there a way to use the lookupvalue function to put the selected value in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/is-there-a-way-to-use-the-lookupvalue-function-to-put-the/m-p/860578#M42363</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A search for lookupvalue on documentation.sas.com gets zero results, so where did you find that (provide a link)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Lookupvalue is not a SAS language function, it's apparently a function in the SAS Intelligent Decisioning product (solution?):&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/edmcdc/5.4/edmug/n0tamns22magmun1fhnw8mu61k4i.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/edmcdc/5.4/edmug/n0tamns22magmun1fhnw8mu61k4i.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess it's a Viya product/solution?&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.sas.com/en_us/software/intelligent-decisioning.html" target="_blank"&gt;https://www.sas.com/en_us/software/intelligent-decisioning.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 22:28:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/is-there-a-way-to-use-the-lookupvalue-function-to-put-the/m-p/860578#M42363</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-02-23T22:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: is there a way to use the lookupvalue function to put the selected value in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/is-there-a-way-to-use-the-lookupvalue-function-to-put-the/m-p/860589#M42364</link>
      <description>&lt;P&gt;Here's how a lookup format can work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DirInfo1;
   input label $ start : $12. ;
fmtname = '$codeid';
   datalines;
1A2345 IA
1B2354 Promutuel
1C2366 Desjardins
1D2378 TD
run;

proc format cntlin = DirInfo1;
run;

data _null_;
  name = 'TD';
  codeid = put(name, $codeid.);
  put _all_;
run;

%let name = TD;
%let codeid = %sysfunc(putc(&amp;amp;name, $codeid.));
%put codeid = &amp;amp;codeid;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Feb 2023 00:07:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/is-there-a-way-to-use-the-lookupvalue-function-to-put-the/m-p/860589#M42364</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-02-24T00:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: is there a way to use the lookupvalue function to put the selected value in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/is-there-a-way-to-use-the-lookupvalue-function-to-put-the/m-p/860605#M42365</link>
      <description>&lt;P&gt;But this means it is part of that product's specific "language" and cannot be used in a SAS Foundation DATA step.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 05:42:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/is-there-a-way-to-use-the-lookupvalue-function-to-put-the/m-p/860605#M42365</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-24T05:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: is there a way to use the lookupvalue function to put the selected value in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/is-there-a-way-to-use-the-lookupvalue-function-to-put-the/m-p/860606#M42366</link>
      <description>&lt;P&gt;After &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp;'s post, I think this can do what you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DirInfo1;
input codeid $ name $ ;
datalines;
1A2345 IA
1B2354 Promutuel
1C2366 Desjardins
1D2378 TD
;
data want;
set have;
if _n_ = 1
then do;
  length codeid $8;
  declare hash lookup (dataset:"dirinfo1");
  lookup.definekey("name");
  lookup.definedata("codeid");
  lookup.definedone();
end;
if lookup.find() ne 0 then codeid = "";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The "have" dataset has the variable name which you want to find the codeid for. "have" should not already have a variable codeid.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 05:52:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/is-there-a-way-to-use-the-lookupvalue-function-to-put-the/m-p/860606#M42366</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-24T05:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: is there a way to use the lookupvalue function to put the selected value in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/is-there-a-way-to-use-the-lookupvalue-function-to-put-the/m-p/860660#M42374</link>
      <description>This code will be useful too.  Thank you very much</description>
      <pubDate>Fri, 24 Feb 2023 13:15:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/is-there-a-way-to-use-the-lookupvalue-function-to-put-the/m-p/860660#M42374</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2023-02-24T13:15:42Z</dc:date>
    </item>
    <item>
      <title>Re: is there a way to use the lookupvalue function to put the selected value in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/is-there-a-way-to-use-the-lookupvalue-function-to-put-the/m-p/860661#M42375</link>
      <description>Thank you very for showing me how to use that function</description>
      <pubDate>Fri, 24 Feb 2023 13:17:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/is-there-a-way-to-use-the-lookupvalue-function-to-put-the/m-p/860661#M42375</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2023-02-24T13:17:48Z</dc:date>
    </item>
  </channel>
</rss>

