<?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 Case Statement from a Macro: Possible? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Case-Statement-from-a-Macro-Possible/m-p/460068#M284625</link>
    <description>&lt;P&gt;I have a case statement that will need to be used in multiple PROC SQL procedures and wanted to see if this can be stored in a macro similar to how it can be done with an IN statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Case Statement Sample:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;case&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.FIELD_NM &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;IN&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'EAGLE'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;THEN&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'BIRD'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.FIELD_NM &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;IN&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'SALMON'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;THEN&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'FISH'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'NA'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; CLASS_NM&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Can it be done doing something like this?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%LET CASETEST =&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.FIELD_NM &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;IN&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'EAGLE'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;THEN&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'BIRD'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.FIELD_NM &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;IN&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'SALMON'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;THEN&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'FISH'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;Then in PROC SQL Call as (probably have the syntax wrong):&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;case&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT face="Courier New"&gt;&amp;amp;CASETEST&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'NA'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; CLASS_NM&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Thanks in advance.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 04 May 2018 14:58:44 GMT</pubDate>
    <dc:creator>PhatRam33</dc:creator>
    <dc:date>2018-05-04T14:58:44Z</dc:date>
    <item>
      <title>Case Statement from a Macro: Possible?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-Statement-from-a-Macro-Possible/m-p/460068#M284625</link>
      <description>&lt;P&gt;I have a case statement that will need to be used in multiple PROC SQL procedures and wanted to see if this can be stored in a macro similar to how it can be done with an IN statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Case Statement Sample:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;case&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.FIELD_NM &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;IN&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'EAGLE'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;THEN&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'BIRD'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.FIELD_NM &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;IN&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'SALMON'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;THEN&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'FISH'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'NA'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; CLASS_NM&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Can it be done doing something like this?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%LET CASETEST =&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.FIELD_NM &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;IN&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'EAGLE'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;THEN&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'BIRD'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.FIELD_NM &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;IN&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'SALMON'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;THEN&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'FISH'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;Then in PROC SQL Call as (probably have the syntax wrong):&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;case&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT face="Courier New"&gt;&amp;amp;CASETEST&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'NA'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; CLASS_NM&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Thanks in advance.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 14:58:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-Statement-from-a-Macro-Possible/m-p/460068#M284625</guid>
      <dc:creator>PhatRam33</dc:creator>
      <dc:date>2018-05-04T14:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: Case Statement from a Macro: Possible?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-Statement-from-a-Macro-Possible/m-p/460072#M284626</link>
      <description>&lt;P&gt;You could but that seems like a horrible design.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're doing look ups with the lookup tables known, I would suggest using a custom user defined format instead. Much easier to manage in the long run.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/41922"&gt;@PhatRam33&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I have a case statement that will need to be used in multiple PROC SQL procedures and wanted to see if this can be stored in a macro similar to how it can be done with an IN statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Case Statement Sample:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;case&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.FIELD_NM &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;IN&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'EAGLE'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;THEN&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#800080"&gt;'BIRD'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.FIELD_NM &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;IN&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'SALMON'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;THEN&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#800080"&gt;'FISH'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;else&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#800080"&gt;'NA'&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;end&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; CLASS_NM&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Can it be done doing something like this?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%LET CASETEST =&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.FIELD_NM &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;IN&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'EAGLE'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;THEN&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#800080"&gt;'BIRD'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.FIELD_NM &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;IN&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'SALMON'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;THEN&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#800080"&gt;'FISH'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;Then in PROC SQL Call as (probably have the syntax wrong):&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;case&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;&lt;FONT face="Courier New"&gt;&amp;amp;CASETEST&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;else&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#800080"&gt;'NA'&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;end&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; CLASS_NM&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Thanks in advance.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 15:05:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-Statement-from-a-Macro-Possible/m-p/460072#M284626</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-04T15:05:51Z</dc:date>
    </item>
    <item>
      <title>Re: Case Statement from a Macro: Possible?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-Statement-from-a-Macro-Possible/m-p/460085#M284627</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;will need to be used in multiple PROC SQL procedures" - then put the data into a dataset and use merging, or lookups.&amp;nbsp; I.e. a table:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;FIELD_NAME&amp;nbsp; CATEGORY&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;EAGLE&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;BIRD&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;SALMON&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FISH&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Then merge that on by FIELD_NAME.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 15:23:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-Statement-from-a-Macro-Possible/m-p/460085#M284627</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-04T15:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: Case Statement from a Macro: Possible?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-Statement-from-a-Macro-Possible/m-p/460104#M284628</link>
      <description>&lt;P&gt;Here is a very brief example implementing &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;'s format approach.&lt;/P&gt;
&lt;PRE&gt;Proc format library=work;
value $lookup
'EAGLE', 'SPARROW','OWL'='BIRD'
'SALMON','TROUT','BASS' ='FISH'
;
RUN;

DATA work.have;
    input animal $;
datalines;
EAGLE
SPARROW
OWL
SALMON
TROUT
BASS 
;
run;

proc sql;
   create table want as
   select animal, put(animal,$lookup.) as Class_nm
   from work.have
   ;
quit;
&lt;/PRE&gt;
&lt;P&gt;However it may not be needed to add a variable at all. SAS will recognize the formatted value for most analysis procedures.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc freq data=work.have;
   tables animal;
   format animal $lookup.;
run;&lt;/PRE&gt;
&lt;P&gt;Of course in most reports you could also assign a format and get the desired display value from the variable using a format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the list is to be used frequently then creating the format(s) and placing them in a permanent library with your SAS FMTSEARCH option set to look there means that the format code need not be run every time it is used and can be share by others. If you use this approach I suggest using the CNTLOUT option in Proc Format to create a data set that can be used to recreate the formats in case someone "misplaces" the format source code.&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 17:06:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-Statement-from-a-Macro-Possible/m-p/460104#M284628</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-05-04T17:06:26Z</dc:date>
    </item>
  </channel>
</rss>

