<?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: First When clause works for renaming, second one fails??? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/First-When-clause-works-for-renaming-second-one-fails/m-p/345721#M79574</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;as far as I can see, your code is OK. But check your data, you might have leading or trailing blanks in &lt;FONT color="#008000"&gt;Appl_Store_Number/IPADDRESS&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try [...] &lt;FONT color="#008000"&gt;when strip(Appl_Store_Number)='9990' and strip(IPADDRESS)='50.235.193.210' then '9481'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
   CREATE TABLE CLASS AS
   SELECT *,
          CASE
              WHEN age eq 12 AND substr(name,1,1) eq 'J' THEN 'J'
              WHEN age eq 12 AND substr(name,1,1) eq 'L' THEN 'L'
              WHEN age eq 12 AND substr(name,1,1) eq 'R' THEN 'R'
              ELSE 'XX '||name||' XX'
          END AS STore_no
   FROM sashelp.class
   ORDER BY age, name
   ;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;btw sort directly in SQL&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 30 Mar 2017 12:19:54 GMT</pubDate>
    <dc:creator>Oligolas</dc:creator>
    <dc:date>2017-03-30T12:19:54Z</dc:date>
    <item>
      <title>First When clause works for renaming, second one fails???</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-When-clause-works-for-renaming-second-one-fails/m-p/343400#M78833</link>
      <description>&lt;P&gt;so, in an effort to rename certain things in this code i've done the following.. .not sure why the second where statement is failing to rename the ip info, in fact it doesn't show up at all in my final data set? ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;connect to netezza(server=uxcrdbp3 database=EDW_METRICS_NZ_PROD01 authdomain=NZAuth);&lt;BR /&gt;create table work.apps as&lt;BR /&gt;select * from connection to netezza&lt;BR /&gt;( select a.div_no&lt;BR /&gt;,a.application_id&lt;BR /&gt;,a.appl_store_number&lt;BR /&gt;,a.card_purch_actv_store_no&lt;BR /&gt;,a.entry_Date&lt;BR /&gt;,a.true_app_ind&lt;BR /&gt;,b.ipaddress&lt;BR /&gt;,b.IP_LOC_CITY&lt;BR /&gt;,b.DEVICE_ALIAS&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;from nzschema.application_curr_vw A&lt;BR /&gt;left join&lt;BR /&gt;EDW_NZ_PROD01.nzschema.IOVLOG_IOVAT_LOG B&lt;BR /&gt;on a.application_id=b.application_id&lt;/P&gt;&lt;P&gt;where a.entry_date between &amp;amp;date1 and &amp;amp;date30&lt;BR /&gt;and a.div_no in (&amp;amp;DivNo)&lt;BR /&gt;and a.true_app_ind=1&lt;BR /&gt;and a.appl_store_number not in(&amp;amp;Test_Store));&lt;BR /&gt;quit;&lt;BR /&gt;/* When the application is from a web location "store 9990", this orders the web application to the proper store#*/&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000"&gt;proc sql;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;create table work.apps1 as&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;select *&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;,case/*Store Num 9481*/&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;when Appl_Store_Number='9990' and card_purch_actv_store_no&amp;gt;0 then left(put(card_purch_actv_store_no,7.))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;when Appl_Store_Number='9990' and IPADDRESS='50.235.193.210' then '9481'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;when Appl_Store_Number='9990' and IPADDRESS='172.58.11.96' then '9481567'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;when Appl_Store_Number='9990' and IPADDRESS='50.128.141.125' then '9481IP3'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;when Appl_Store_Number='9990' and IPADDRESS='50.243.249.213' then '9481004IP'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;when Appl_Store_Number='9990' and IPADDRESS='70.126.152.26' then '9481005 IP address'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;when Appl_Store_Number='9990' and IPADDRESS='73.54.9.192' then '9481006 IP address'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;when Appl_Store_Number='9990' and IPADDRESS='76.108.188.73' then '9481007 IP address'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;when Appl_Store_Number='9990' and IPADDRESS='99.159.198.76' then '9481008 IP address'&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;/*Store Num 6181*/&lt;BR /&gt;when Appl_Store_Number='9990' and IPADDRESS='162.199.196.117' then '6181 IP address/activation'&lt;/P&gt;&lt;P&gt;/*Store Num 6451*/&lt;BR /&gt;when Appl_Store_Number='9990' and IPADDRESS='74.64.27.127' then '6451 IP address/activation'&lt;/P&gt;&lt;P&gt;/*Store Num 8001*/&lt;BR /&gt;when Appl_Store_Number='9990' and IPADDRESS='50.186.155.15' then '8001 IP address/activation'&lt;/P&gt;&lt;P&gt;/*Store Num 5631*/&lt;BR /&gt;when Appl_Store_Number='9990' and IPADDRESS='98.148.135.186' then '5631 IP address/activation'&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000"&gt;/*Store Num 2131*/&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;when Appl_Store_Number='9990' and IPADDRESS='98.148.135.186' then '2131 IP address/activation'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;when Appl_Store_Number='9990' and IPADDRESS='71.240.170.83' then '2131 IP address/activation'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;/*Store Num 581*/&lt;BR /&gt;when Appl_Store_Number='9990' and IPADDRESS='67.77.44.26' then '581 IP address/activation'&lt;/P&gt;&lt;P&gt;/*Store Num 6681*/&lt;BR /&gt;when Appl_Store_Number='9990' and IPADDRESS='50.248.9.113' then '6681 IP address/activation'&lt;/P&gt;&lt;P&gt;when Appl_Store_Number='9990' then 'x'||(IPADDRESS)&lt;BR /&gt;else Appl_Store_Number end as Store_No&lt;BR /&gt;&lt;BR /&gt;from work.apps;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;/*This orders the raw data by DIV Store Num and transaction date.*/&lt;BR /&gt;proc sort;&lt;BR /&gt;by div_no store_no entry_date;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 16:45:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-When-clause-works-for-renaming-second-one-fails/m-p/343400#M78833</guid>
      <dc:creator>EBrunetti</dc:creator>
      <dc:date>2017-03-22T16:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: First When clause works for renaming, second one fails???</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-When-clause-works-for-renaming-second-one-fails/m-p/345673#M79554</link>
      <description>&lt;P&gt;&lt;SPAN&gt;i think you are missed to assign the character format to the variable Store_No&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 08:02:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-When-clause-works-for-renaming-second-one-fails/m-p/345673#M79554</guid>
      <dc:creator>Madansas7b</dc:creator>
      <dc:date>2017-03-30T08:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: First When clause works for renaming, second one fails???</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-When-clause-works-for-renaming-second-one-fails/m-p/345721#M79574</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;as far as I can see, your code is OK. But check your data, you might have leading or trailing blanks in &lt;FONT color="#008000"&gt;Appl_Store_Number/IPADDRESS&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try [...] &lt;FONT color="#008000"&gt;when strip(Appl_Store_Number)='9990' and strip(IPADDRESS)='50.235.193.210' then '9481'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
   CREATE TABLE CLASS AS
   SELECT *,
          CASE
              WHEN age eq 12 AND substr(name,1,1) eq 'J' THEN 'J'
              WHEN age eq 12 AND substr(name,1,1) eq 'L' THEN 'L'
              WHEN age eq 12 AND substr(name,1,1) eq 'R' THEN 'R'
              ELSE 'XX '||name||' XX'
          END AS STore_no
   FROM sashelp.class
   ORDER BY age, name
   ;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;btw sort directly in SQL&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 12:19:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-When-clause-works-for-renaming-second-one-fails/m-p/345721#M79574</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2017-03-30T12:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: First When clause works for renaming, second one fails???</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-When-clause-works-for-renaming-second-one-fails/m-p/345748#M79586</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When the type and length of a variable are not explicitly set, SAS gives the variable a default type and length as shown in bellow&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;STRONG&gt;x='ABC';&lt;/STRONG&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;STRONG&gt;x='ABCDE';&lt;/STRONG&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;here it will consider as per first obs length&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&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, 30 Mar 2017 14:00:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-When-clause-works-for-renaming-second-one-fails/m-p/345748#M79586</guid>
      <dc:creator>Madansas7b</dc:creator>
      <dc:date>2017-03-30T14:00:18Z</dc:date>
    </item>
  </channel>
</rss>

