<?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: Extract value from a column based on other column to make a new column using proc sql/query buil in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Extract-value-from-a-column-based-on-other-column-to-make-a-new/m-p/561988#M10676</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    create table want as select case when attrrecno=389 then 
              phnumber else . end as home_number,
          select case when attrrecno=391 then phnumber else . end 
                  as mobile_number,
          attrrecno 
     from have;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 28 May 2019 14:55:02 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-05-28T14:55:02Z</dc:date>
    <item>
      <title>Extract value from a column based on other column to make a new column using proc sql/query builder</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extract-value-from-a-column-based-on-other-column-to-make-a-new/m-p/561986#M10675</link>
      <description>&lt;P&gt;I'm using proc sql code to create a table that displays output data as below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;phnumber&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Attrrecno&lt;/P&gt;&lt;P&gt;444333888&amp;nbsp;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 389&lt;/P&gt;&lt;P&gt;4328883333&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 391&lt;/P&gt;&lt;P&gt;8388888833&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 389&lt;/P&gt;&lt;P&gt;8388283888&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 391&lt;/P&gt;&lt;P&gt;82383838383&amp;nbsp;&amp;nbsp;&amp;nbsp; 389&lt;/P&gt;&lt;P&gt;99293939393&amp;nbsp;&amp;nbsp;&amp;nbsp; 391&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My issue is, I need to create separate columns for the data under the phnumber column.&amp;nbsp; The new columns will contain either a mobile phone number or home phone number based on the value under attrrecno.&amp;nbsp; If attreccno is 389, it's home number.&amp;nbsp; If 391 it is mobile.&amp;nbsp; Using proc sql how do I do this.&amp;nbsp; Or, can it be done on the output side using SAS EG Query&amp;nbsp; Builder? I'm sending attachment as well to show my current proc sql code.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 14:50:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extract-value-from-a-column-based-on-other-column-to-make-a-new/m-p/561986#M10675</guid>
      <dc:creator>req41273</dc:creator>
      <dc:date>2019-05-28T14:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: Extract value from a column based on other column to make a new column using proc sql/query buil</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extract-value-from-a-column-based-on-other-column-to-make-a-new/m-p/561988#M10676</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    create table want as select case when attrrecno=389 then 
              phnumber else . end as home_number,
          select case when attrrecno=391 then phnumber else . end 
                  as mobile_number,
          attrrecno 
     from have;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 May 2019 14:55:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extract-value-from-a-column-based-on-other-column-to-make-a-new/m-p/561988#M10676</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-05-28T14:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: Extract value from a column based on other column to make a new column using proc sql/query buil</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extract-value-from-a-column-based-on-other-column-to-make-a-new/m-p/562008#M10677</link>
      <description>&lt;P&gt;Will try your suggestion.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, received&amp;nbsp; following suggestion (see attachment doc).&amp;nbsp; Getting a syntax error regarding the select subqueries.&amp;nbsp; SAS error says expecting a , ), &amp;lt;&amp;gt;. and, or, between, etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you see anything wrong with the code syntax in the attachment that would cause this error?&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 16:10:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extract-value-from-a-column-based-on-other-column-to-make-a-new/m-p/562008#M10677</guid>
      <dc:creator>req41273</dc:creator>
      <dc:date>2019-05-28T16:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: Extract value from a column based on other column to make a new column using proc sql/query buil</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extract-value-from-a-column-based-on-other-column-to-make-a-new/m-p/562020#M10683</link>
      <description>&lt;P&gt;Post a copy of the SAS log with the error message. Do NOT attach a file. Instead use the Insert Code button in the forum editor (looks like {i}) to get a pop-up window that you can use to paste the text lines from the log.&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 17:12:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extract-value-from-a-column-based-on-other-column-to-make-a-new/m-p/562020#M10683</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-28T17:12:39Z</dc:date>
    </item>
    <item>
      <title>Re: Extract value from a column based on other column to make a new column using proc sql/query buil</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extract-value-from-a-column-based-on-other-column-to-make-a-new/m-p/562037#M10690</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Post a copy of the SAS log with the error message. Do NOT attach a file. Instead use the Insert Code button in the forum editor (looks like {i}) to get a pop-up window that you can use to paste the text lines from the log.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And it is not even a log entry.&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 18:03:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extract-value-from-a-column-based-on-other-column-to-make-a-new/m-p/562037#M10690</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-28T18:03:01Z</dc:date>
    </item>
  </channel>
</rss>

