<?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: %Let with Zip Codes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Let-with-Zip-Codes/m-p/526157#M143233</link>
    <description>&lt;P&gt;PROC SQL doesn't need commas in IN operator lists either.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1     proc sql ;
2     select count(*) from sashelp.class
3     where age in (12 13)
4     ;
5     quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.24 seconds
      cpu time            0.09 seconds
&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Unless you are explicitly writing SQL for a foreign database by using EXECUTE or CONNECTION TO.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 10 Jan 2019 19:06:21 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-01-10T19:06:21Z</dc:date>
    <item>
      <title>%Let with Zip Codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Let-with-Zip-Codes/m-p/526151#M143228</link>
      <description>&lt;P&gt;Quick Question:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's say we have a variable named ZIP and we want a macro that does offer an early filter on specific zip codes:&lt;/P&gt;
&lt;P&gt;I am aware that %LET works with text...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How I can work it out with numbers having something like that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%LET Zip = 28201, 28203, 28204, 28205;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and then how we call it...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;AND X.ZIP IN (&amp;amp;Zip.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 18:52:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Let-with-Zip-Codes/m-p/526151#M143228</guid>
      <dc:creator>triunk</dc:creator>
      <dc:date>2019-01-10T18:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: %Let with Zip Codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Let-with-Zip-Codes/m-p/526152#M143229</link>
      <description>&lt;P&gt;Not sure what the question is.&lt;/P&gt;
&lt;P&gt;Personally I wouldn't include the commas.&amp;nbsp; The IN operator in SAS doesn't need them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also ZIP should really be a CHAR variable and not a numeric variable.&amp;nbsp; Otherwise zip code in the NorthEast look funny without the leading zeros and there is no way to handle ZIP+4 codes.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 18:56:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Let-with-Zip-Codes/m-p/526152#M143229</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-01-10T18:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: %Let with Zip Codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Let-with-Zip-Codes/m-p/526153#M143230</link>
      <description>&lt;P&gt;Two key points here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;numbers are text in the macro processor&lt;/LI&gt;
&lt;LI&gt;when you use the macro variable and the macro variable is resolved into text, the the SAS code must be valid legal SAS code&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, if X.ZIP is numeric, the valid SAS code is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;and x.zip in (28201, 28203, 28204, 28205)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thus, if you use the %LET statement as you wrote it, I believe it should work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;... we want a macro that does ...&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, for complete clarity, and to avoid miscommunications in the future, do not refer to this as a macro. The variable &amp;amp;ZIP is a macro variable, not a macro. The %LET command is a macro command, not a macro.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 18:58:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Let-with-Zip-Codes/m-p/526153#M143230</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-01-10T18:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: %Let with Zip Codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Let-with-Zip-Codes/m-p/526154#M143231</link>
      <description>&lt;P&gt;If you are using it with proc sql then yes, that is correct.&lt;/P&gt;&lt;P&gt;If you are calling it within anything else then you probably don't need the commas.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 18:59:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Let-with-Zip-Codes/m-p/526154#M143231</guid>
      <dc:creator>DanielLangley</dc:creator>
      <dc:date>2019-01-10T18:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: %Let with Zip Codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Let-with-Zip-Codes/m-p/526157#M143233</link>
      <description>&lt;P&gt;PROC SQL doesn't need commas in IN operator lists either.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1     proc sql ;
2     select count(*) from sashelp.class
3     where age in (12 13)
4     ;
5     quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.24 seconds
      cpu time            0.09 seconds
&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Unless you are explicitly writing SQL for a foreign database by using EXECUTE or CONNECTION TO.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 19:06:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Let-with-Zip-Codes/m-p/526157#M143233</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-01-10T19:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: %Let with Zip Codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Let-with-Zip-Codes/m-p/526161#M143236</link>
      <description>&lt;P&gt;It still show an error saying in both cases (with comas and not comas and with let and/or hard code in proc sql):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"Expression using IN has components that are of different data types"&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 19:13:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Let-with-Zip-Codes/m-p/526161#M143236</guid>
      <dc:creator>triunk</dc:creator>
      <dc:date>2019-01-10T19:13:07Z</dc:date>
    </item>
    <item>
      <title>Re: %Let with Zip Codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Let-with-Zip-Codes/m-p/526163#M143238</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/36222"&gt;@triunk&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;It still says in both cases (with comas and not comas and with let and/or hard code in proc sql):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"Expression using IN has components that are of different data types"&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It would say that if&amp;nbsp;ZIP is actually a character variable? Is it?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 19:15:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Let-with-Zip-Codes/m-p/526163#M143238</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-01-10T19:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: %Let with Zip Codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Let-with-Zip-Codes/m-p/526164#M143239</link>
      <description>&lt;P&gt;It is a character... thank you and my apologies to all for my silly question.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 19:15:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Let-with-Zip-Codes/m-p/526164#M143239</guid>
      <dc:creator>triunk</dc:creator>
      <dc:date>2019-01-10T19:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: %Let with Zip Codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Let-with-Zip-Codes/m-p/526166#M143241</link>
      <description>&lt;P&gt;There are only two data types in SAS:&amp;nbsp; character and numeric.&amp;nbsp; So that error messing is confirming that ZIP is a character variable.&amp;nbsp; If you want the items in your IN list to be character, you need to put them in quotes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
and x.zip in ("28201", "28203", "28204", "28205")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Commas are optional, and macro language has nothing to do with it.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 19:15:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Let-with-Zip-Codes/m-p/526166#M143241</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-01-10T19:15:55Z</dc:date>
    </item>
  </channel>
</rss>

