<?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: Insert condition into proc sql create table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Insert-condition-into-proc-sql-create-table/m-p/564851#M158484</link>
    <description>&lt;P&gt;like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select a.ACCOUNT_ID
     , a.DATE
     , ifc(b.LETTER='Yes', 'Yes', 'No') as LETTER length=3&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 10 Jun 2019 11:22:13 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2019-06-10T11:22:13Z</dc:date>
    <item>
      <title>Insert condition into proc sql create table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-condition-into-proc-sql-create-table/m-p/564842#M158480</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a proc sql table that I have created but can anyone help me out with code (and where to insert it) so that missing values/not 'Yes' for the variable 'letter' in the created table VOLUMES (all of the accounts in b.letter have 'Yes' and when I left join, I want the records in the VOLUMES table that do not get assigned 'Yes' to be assigned 'No') are changed to a No i.e.&amp;nbsp;(the condition I want to include is that &lt;FONT color="#FF0000"&gt;if letter = . or letter in the created VOLUMES table is not equal to 'Yes', then letter = 'No'&lt;/FONT&gt;)? Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would there be code so it creates an output similar to an example I've created below?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Volumes.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30152i27EE3FF848B999A7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Volumes.PNG" alt="Volumes.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In&amp;nbsp;ac.letters as a:&lt;/P&gt;&lt;P&gt;-There is no letter variable but when I left join&amp;nbsp;rb.account_information as b, I would like the records that are not matched by account ID to have 'No' assigned in the newly created VOLUMES table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In&amp;nbsp;rb.account_information as b:&lt;/P&gt;&lt;P&gt;-All of the records are assigned 'Yes' for the letter variable and this dataset will be left joined onto the ac.letters dataset to match the account ID and therefore give the matched accounts a 'Yes' answer for the letter variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Code so far:&lt;/U&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; create table VOLUMES as&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; select a.account_id,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; a.date,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; b.letter&lt;BR /&gt;&amp;nbsp; &amp;nbsp; from ac.letters as a&lt;BR /&gt;&amp;nbsp; &amp;nbsp;left join rb.account_information as b&lt;BR /&gt;&amp;nbsp; &amp;nbsp; on a.account_id = b.ACCOUNT_ID&lt;BR /&gt;&amp;nbsp; &amp;nbsp;;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2019 11:29:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-condition-into-proc-sql-create-table/m-p/564842#M158480</guid>
      <dc:creator>jeremy4</dc:creator>
      <dc:date>2019-06-10T11:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: Insert condition into proc sql create table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-condition-into-proc-sql-create-table/m-p/564845#M158481</link>
      <description>&lt;P&gt;Could you please explain with any sample dataset/table.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2019 10:03:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-condition-into-proc-sql-create-table/m-p/564845#M158481</guid>
      <dc:creator>Sathish_jammy</dc:creator>
      <dc:date>2019-06-10T10:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: Insert condition into proc sql create table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-condition-into-proc-sql-create-table/m-p/564849#M158483</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I can't provide any samples because of confidentiality issues but I have included more information in my description above, if that helps?</description>
      <pubDate>Mon, 10 Jun 2019 10:44:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-condition-into-proc-sql-create-table/m-p/564849#M158483</guid>
      <dc:creator>jeremy4</dc:creator>
      <dc:date>2019-06-10T10:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: Insert condition into proc sql create table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-condition-into-proc-sql-create-table/m-p/564851#M158484</link>
      <description>&lt;P&gt;like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select a.ACCOUNT_ID
     , a.DATE
     , ifc(b.LETTER='Yes', 'Yes', 'No') as LETTER length=3&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2019 11:22:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-condition-into-proc-sql-create-table/m-p/564851#M158484</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-06-10T11:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: Insert condition into proc sql create table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-condition-into-proc-sql-create-table/m-p/564854#M158485</link>
      <description>Hi Chris,&lt;BR /&gt;&lt;BR /&gt;Thanks for your reply. I've added in a diagram to help with the explanation but all of the records in dataset b (rb.account_information) all have been assigned 'Yes' for the letter variable. When I left join to dataset a, I would like all of the matched account ID accounts to therefore have the 'Yes' answer for the letter variable in the proc sql VOLUMES table.&lt;BR /&gt;&lt;BR /&gt;When the account ID's between the two datasets do not match (i.e. could the code wait until the VOLUMES table is created and then assign a 'No' to the unmatched account ID's, instead of putting code for 'No' from dataset b, as this would not help since all of the records in dataset b have been assigned 'Yes')? Thanks!</description>
      <pubDate>Mon, 10 Jun 2019 11:35:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-condition-into-proc-sql-create-table/m-p/564854#M158485</guid>
      <dc:creator>jeremy4</dc:creator>
      <dc:date>2019-06-10T11:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: Insert condition into proc sql create table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-condition-into-proc-sql-create-table/m-p/564858#M158486</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt; a&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;ACCOUNT_ID
     &lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; a&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;DATE&lt;/SPAN&gt;
     &lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;ifc&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;a.ACCOUNT_ID is null&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; 'No', &lt;SPAN class="token string"&gt;'Yes'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; as LETTER &lt;SPAN class="token function"&gt;length&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, you seem to want a full join rather than a left join?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2019 11:40:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-condition-into-proc-sql-create-table/m-p/564858#M158486</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-06-10T11:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: Insert condition into proc sql create table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-condition-into-proc-sql-create-table/m-p/564861#M158487</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I've been asked to do a left join because I would like to keep all of the contents of dataset a (the diagram above was just a small example but there are thousands of records in my dataset) and when dataset b is left joined onto dataset a to assign 'Yes' when the account ID's match, I would like the remaining unmatched ID's from the created VOLUMES table to then be assigned 'No' for the letter variable.</description>
      <pubDate>Mon, 10 Jun 2019 11:45:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-condition-into-proc-sql-create-table/m-p/564861#M158487</guid>
      <dc:creator>jeremy4</dc:creator>
      <dc:date>2019-06-10T11:45:26Z</dc:date>
    </item>
    <item>
      <title>Re: Insert condition into proc sql create table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-condition-into-proc-sql-create-table/m-p/564868#M158488</link>
      <description>I've just used your code but it has put all of the records in the VOLUMES table as having 'Yes' in the letter variable, but from using my initial code, I think there should be a mixture of 'Yes' and 'No' answers as not all account ID's match between the two datasets. Is there any way for the code to be edited so that 'No' is applied only after the VOLUMES table has been created and then when letter is not 'Yes', then it will update the table so that the other answers are 'No'? Thanks!&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table VOLUMES as&lt;BR /&gt;select ifc(a.ACCOUNT_ID is null, 'No', 'Yes') as LETTER length=3,&lt;BR /&gt;a.date,&lt;BR /&gt;b.letter&lt;BR /&gt;from ac.letters as a&lt;BR /&gt;left join rb.account_information as b&lt;BR /&gt;on a.account_id = b.ACCOUNT_ID&lt;BR /&gt;;&lt;BR /&gt;quit;</description>
      <pubDate>Mon, 10 Jun 2019 11:51:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-condition-into-proc-sql-create-table/m-p/564868#M158488</guid>
      <dc:creator>jeremy4</dc:creator>
      <dc:date>2019-06-10T11:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: Insert condition into proc sql create table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-condition-into-proc-sql-create-table/m-p/564870#M158489</link>
      <description>&lt;P&gt;None of my proposals work?&lt;/P&gt;
&lt;P&gt;Please provide sample data and expected output for that exact data.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2019 12:05:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-condition-into-proc-sql-create-table/m-p/564870#M158489</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-06-10T12:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: Insert condition into proc sql create table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-condition-into-proc-sql-create-table/m-p/564876#M158491</link>
      <description>&lt;P&gt;Hi, I used your ifc concept because that was correct and changed it so that it was when letter is null (i.e. mix and match of both of your suggestions) and it's worked, thanks a lot for your help!&lt;BR /&gt;&lt;BR /&gt;&lt;U&gt;Correct code to use:&lt;/U&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;create table VOLUMES as&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; select a.account_id,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; a.date,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ifc(b.letter is null, 'No', 'Yes') as letter length=3&lt;BR /&gt;&amp;nbsp; &amp;nbsp; from ac.letters as a&lt;BR /&gt;&amp;nbsp; &amp;nbsp;left join rb.account_information as b&lt;BR /&gt;&amp;nbsp; &amp;nbsp;on a.account_id = b.ACCOUNT_ID&lt;BR /&gt;&amp;nbsp; &amp;nbsp;;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2019 12:23:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-condition-into-proc-sql-create-table/m-p/564876#M158491</guid>
      <dc:creator>jeremy4</dc:creator>
      <dc:date>2019-06-10T12:23:31Z</dc:date>
    </item>
  </channel>
</rss>

