<?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: Storing a long repeated WHERE condition in a macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Storing-a-long-repeated-WHERE-condition-in-a-macro-variable/m-p/193621#M305035</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Chang,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you copied the code as it appears in the paper, you would have given WHERE_STRING a length of $5000.&amp;nbsp; That's not enough to hold the logic for 692 categories.&amp;nbsp; Increasing it to $15000 should do the trick in the simplest fashion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also note, since you are using this WHERE clause in a DATA step, there are other constructs that would work and don't involve such a long string.&amp;nbsp; For example, consider:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where (DX1 like "196%" or DX1 like "197%" or DX1 like "198%");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This could be replaced with:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where DX1 in: ("196", "197", "198");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don't forget the colon after IN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 01 Jul 2015 15:42:06 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2015-07-01T15:42:06Z</dc:date>
    <item>
      <title>Storing a long repeated WHERE condition in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Storing-a-long-repeated-WHERE-condition-in-a-macro-variable/m-p/193619#M305033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to create a where statement using a string value from a macro variable. My where statement is basically a repetition of "variable like 'value%' where the variable is a single variable and the value is a particular ICD-9-CM code. An example would be&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where (DX1 like "196%" or DX1 like "197%" or DX1 like "198%" or DX1 like "199%" or DX1 like "40201%" or DX1 like "40211%" or DX1 like "40291%" or DX1 like "4293%" or DX1 like "425%" or DX1 like "428%" or DX1 like "3310%" or DX1 like "3311%" or DX1 like "3312%" or DX1 like "290%" or DX1 like "40311%" or DX1 like "40391%" or DX1 like "40412%" or DX1 like "40492%" or DX1 like "585%" or DX1 like "586%" or DX1 like "V420%" or DX1 like "V451%" or DX1 like "V560%" or DX1 like "V568%");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Firstly, I create a dataset &lt;STRONG&gt;combinedcx_02_weighted_diseases.sas7bat&lt;/STRONG&gt; that contain 3 variables- ICD, disease and weight. The ICD variable has 692 ICD-9-CM codes. The disease variable has corresponding disease categories for the codes. Next, I try to store the very long WHERE condition&amp;nbsp; in a macro variable as suggested by William 2013 (&lt;A href="http://analytics.ncsu.edu/sesug/2014/CC-12.pdf" title="http://analytics.ncsu.edu/sesug/2014/CC-12.pdf"&gt;http://analytics.ncsu.edu/sesug/2014/CC-12.pdf ). &lt;/A&gt;Interestingly I found the WHERE condition is truncated&amp;nbsp; in the SAS log by the %PUT statment. Here is how it looks. Note I mark the ending part in red. It is incomplete:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DX1 like "196%" or DX1 like "197%" or DX1 like "198%" or DX1 like "199%" or DX1 like "40201%" or DX1 like "40211%" or DX1 like "40291%" or DX1 like "4293%" or DX1 like "425%" or DX1 like "428%" or DX1 like "3310%" or DX1 like "3311%" or DX1 like "3312%" or DX1 like "290%" or DX1 like "40311%" or DX1 like "40391%" or DX1 like "40412%" or DX1 like "40492%" or DX1 like "585%" or DX1 like "586%" or DX1 like "V420%" or DX1 like "V451%" or DX1 like "V560%" or &lt;SPAN style="color: red;"&gt;DX1 l&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So there are at least two problems with my code. First, there are just 251 values in the condition. But there are 692 values in the data set to read. Next, the condition doesn't end properly. The word "like" has been split. Any idea to store the where condition in the macro variable? I have tried to increase the length of the where_string but it doesn't make a difference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;&amp;lt;paste code&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;The data and the program can be downloaded at&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;A href="http://likecoded.com/download-2/"&gt;http://likecoded.com/download-2/&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jul 2015 14:54:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Storing-a-long-repeated-WHERE-condition-in-a-macro-variable/m-p/193619#M305033</guid>
      <dc:creator>Chang</dc:creator>
      <dc:date>2015-07-01T14:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: Storing a long repeated WHERE condition in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Storing-a-long-repeated-WHERE-condition-in-a-macro-variable/m-p/193620#M305034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; I would say that the string becomes so long that it exceeds the maximal length for the macro variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would suggest to write the code to an external file using &lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt; file 'temp.txt';&lt;/P&gt;&lt;P&gt; put ""&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then use the stored code via %include 'temp.txt'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it works for you,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jakub&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jul 2015 15:07:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Storing-a-long-repeated-WHERE-condition-in-a-macro-variable/m-p/193620#M305034</guid>
      <dc:creator>chrej5am</dc:creator>
      <dc:date>2015-07-01T15:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Storing a long repeated WHERE condition in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Storing-a-long-repeated-WHERE-condition-in-a-macro-variable/m-p/193621#M305035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Chang,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you copied the code as it appears in the paper, you would have given WHERE_STRING a length of $5000.&amp;nbsp; That's not enough to hold the logic for 692 categories.&amp;nbsp; Increasing it to $15000 should do the trick in the simplest fashion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also note, since you are using this WHERE clause in a DATA step, there are other constructs that would work and don't involve such a long string.&amp;nbsp; For example, consider:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where (DX1 like "196%" or DX1 like "197%" or DX1 like "198%");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This could be replaced with:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where DX1 in: ("196", "197", "198");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don't forget the colon after IN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jul 2015 15:42:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Storing-a-long-repeated-WHERE-condition-in-a-macro-variable/m-p/193621#M305035</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-07-01T15:42:06Z</dc:date>
    </item>
  </channel>
</rss>

