<?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: Proc sql question : conditon always true in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-question-conditon-always-true/m-p/92925#M19605</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 24px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;My input data is like below :&lt;/P&gt;&lt;TABLE style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;TBODY style="font-style: inherit; font-family: inherit;"&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;var1&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;var2&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;var3&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;var4&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;a&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;p&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;pen&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;16&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;a&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;p&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;_all_&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;b&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;a&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;pen&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;13&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;b&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;c&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;pencil&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;d&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;e&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;eraser&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;e&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;r&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;sharpner&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;34&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 24px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;And I want output as below :&lt;/P&gt;&lt;TABLE style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;TBODY style="font-style: inherit; font-family: inherit;"&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;var1&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;var2&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;var3&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;var4&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;flag&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;a&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;p&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;pen&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;16&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;y&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;a&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;p&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;_all_&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;3&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;y&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;b&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;a&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;pen&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;13&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;y&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;b&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;c&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;pencil&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;7&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;n&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;d&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;e&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;eraser&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;9&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;n&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;e&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;r&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;sharpner&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;34&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;y&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 24px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;If you look at 2nd observation, its value is less than 10 still its flagged as y , because _all_&amp;nbsp; here means all elements in that group and whenever any one of them satisfies condition all should be flagged as y , for rest of the observations thats not the case...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 28 Jul 2013 01:26:11 GMT</pubDate>
    <dc:creator>forumsguy</dc:creator>
    <dc:date>2013-07-28T01:26:11Z</dc:date>
    <item>
      <title>Proc sql question : conditon always true</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-question-conditon-always-true/m-p/92920#M19600</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;I have to make condition always true irrespective of any value in character variable, I know I could do that for numeric variable like 1=1 but how to do that for character variable is something I am having problems with right now...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I have following code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select var1,var2,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;case&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;var3 when ("_ALL_" ,'1=1')&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;then case&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;when var4&amp;gt;10 then 'y'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;else 'n' end&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;else 'n' end as flag&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Here, "_ALL_" is coming from a macro variable named mac1, however in few cases (like the one mentioned above)I need to get the next case statement&amp;nbsp; executed irrespective of any value.... I used '1'='1'&amp;nbsp; but it doesnt work.. Any ideas...???&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in adavance&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Jul 2013 07:17:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-question-conditon-always-true/m-p/92920#M19600</guid>
      <dc:creator>forumsguy</dc:creator>
      <dc:date>2013-07-27T07:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql question : conditon always true</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-question-conditon-always-true/m-p/92921#M19601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since you want any character value if present to be true&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can try the below code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;/P&gt;&lt;P&gt;select var1,var2,&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;case &lt;/STRONG&gt;&lt;STRONG&gt;when &lt;/STRONG&gt;&lt;STRONG&gt;var3 ne ' '&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;then case&lt;/P&gt;&lt;P&gt;when var4&amp;gt;10 then 'y'&lt;/P&gt;&lt;P&gt;else 'n' end&lt;/P&gt;&lt;P&gt;else 'n' end as flag&lt;/P&gt;&lt;P&gt;from have;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Hope this works&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jagadish&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Jul 2013 07:32:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-question-conditon-always-true/m-p/92921#M19601</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2013-07-27T07:32:32Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql question : conditon always true</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-question-conditon-always-true/m-p/92922#M19602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jagadish, it would work but I want to select only for particular values not for all.. so it's more like in statement. &lt;/P&gt;&lt;P&gt;I am looking for something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when var3 in ('_ALL_','Some value here which will be true only for few observations')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible, or do i need to write another case for that..??&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Jul 2013 08:00:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-question-conditon-always-true/m-p/92922#M19602</guid>
      <dc:creator>forumsguy</dc:creator>
      <dc:date>2013-07-27T08:00:55Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql question : conditon always true</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-question-conditon-always-true/m-p/92923#M19603</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;SELECT NAME,SEX, AGE,&lt;/P&gt;&lt;P&gt;CASE WHEN AGE IN (10,11,12) &lt;/P&gt;&lt;P&gt;THEN CASE&lt;/P&gt;&lt;P&gt;WHEN HEIGHT&amp;gt;10 THEN 'Y'&lt;/P&gt;&lt;P&gt;ELSE 'N' END&lt;/P&gt;&lt;P&gt;ELSE 'N' END AS FLAG&lt;/P&gt;&lt;P&gt;FROM SASHELP.CLASS;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Jul 2013 08:25:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-question-conditon-always-true/m-p/92923#M19603</guid>
      <dc:creator>Scott_Mitchell</dc:creator>
      <dc:date>2013-07-27T08:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql question : conditon always true</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-question-conditon-always-true/m-p/92924#M19604</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is it possible for you to provide the sample data and the output you wish to get to provide better answer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Jul 2013 08:26:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-question-conditon-always-true/m-p/92924#M19604</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2013-07-27T08:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql question : conditon always true</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-question-conditon-always-true/m-p/92925#M19605</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 24px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;My input data is like below :&lt;/P&gt;&lt;TABLE style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;TBODY style="font-style: inherit; font-family: inherit;"&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;var1&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;var2&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;var3&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;var4&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;a&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;p&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;pen&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;16&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;a&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;p&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;_all_&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;b&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;a&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;pen&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;13&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;b&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;c&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;pencil&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;d&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;e&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;eraser&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;e&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;r&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;sharpner&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;34&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 24px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;And I want output as below :&lt;/P&gt;&lt;TABLE style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;TBODY style="font-style: inherit; font-family: inherit;"&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;var1&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;var2&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;var3&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;var4&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;flag&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;a&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;p&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;pen&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;16&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;y&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;a&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;p&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;_all_&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;3&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;y&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;b&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;a&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;pen&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;13&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;y&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;b&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;c&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;pencil&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;7&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;n&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;d&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;e&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;eraser&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;9&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;n&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;e&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;r&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;sharpner&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;34&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; font-style: inherit; font-family: inherit;"&gt;y&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 24px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;If you look at 2nd observation, its value is less than 10 still its flagged as y , because _all_&amp;nbsp; here means all elements in that group and whenever any one of them satisfies condition all should be flagged as y , for rest of the observations thats not the case...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Jul 2013 01:26:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-question-conditon-always-true/m-p/92925#M19605</guid>
      <dc:creator>forumsguy</dc:creator>
      <dc:date>2013-07-28T01:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql question : conditon always true</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-question-conditon-always-true/m-p/92926#M19606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to change the format of your CASE statement to move the variable reference inside the WHEN condition.&lt;/P&gt;&lt;P&gt;Check out the manul page on the CASE statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473682.htm"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473682.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Example&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The following two PROC SQL steps show two equivalent CASE expressions that create a character column with the strings in the THEN clause. The CASE expression in the second PROC SQL step is a shorthand method that is useful when all the comparisons are with the same column.&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select Name, case&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when Continent = 'North America' then 'Continental U.S.'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when Continent = 'Oceania' then 'Pacific Islands'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else 'None'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end as Region&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from states;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select Name, case Continent&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when 'North America' then 'Continental U.S.'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when 'Oceania' then 'Pacific Islands'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else 'None'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end as Region&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from states;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note:&amp;nbsp;&amp;nbsp; When you use the shorthand method, the conditions must all be equality tests. That is, they cannot use comparison operators or other types of operators.&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Jul 2013 01:50:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-question-conditon-always-true/m-p/92926#M19606</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-07-28T01:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql question : conditon always true</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-question-conditon-always-true/m-p/92927#M19607</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use the logic version of the case expression :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select var1,var2,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;case&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when upcase(var3)="_ALL_" or var4&amp;gt;10&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;STRONG&gt;then "y"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;STRONG&gt;else "n"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end as flag&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Jul 2013 01:52:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-question-conditon-always-true/m-p/92927#M19607</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-07-28T01:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql question : conditon always true</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-question-conditon-always-true/m-p/92928#M19608</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks guys.. it worked...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jul 2013 05:24:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-question-conditon-always-true/m-p/92928#M19608</guid>
      <dc:creator>forumsguy</dc:creator>
      <dc:date>2013-07-29T05:24:38Z</dc:date>
    </item>
  </channel>
</rss>

