<?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: making proc sql create table info as using a call execute in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/making-proc-sql-create-table-info-as-using-a-call-execute/m-p/944117#M45238</link>
    <description>&lt;P&gt;Hello, I am using a proc sql because I need to make an inner join from a policies list table.&amp;nbsp; So, imagine that police is the variable name into some datasets and for other dataset it will be agreement_nbr, does the coalescec will work or not?&amp;nbsp; If not, what will be a work around solution.&lt;/P&gt;</description>
    <pubDate>Mon, 16 Sep 2024 17:20:11 GMT</pubDate>
    <dc:creator>alepage</dc:creator>
    <dc:date>2024-09-16T17:20:11Z</dc:date>
    <item>
      <title>making proc sql create table info as using a call execute</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/making-proc-sql-create-table-info-as-using-a-call-execute/m-p/944103#M45236</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have created a SAS dataset which tell me the path, fname and engine to use read the dataset via a call execute.&lt;/P&gt;
&lt;P&gt;The issue, I am facing is that in some dataset the agreement number this value is under the variable police while in other one we have&amp;nbsp; they are under agreement_nbr.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table info as
select police as agreement_nbr
from source
Quit;
 and in some other case we will have
proc sql;
create table info as
select agreement_nbr 
from source
Quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;does a coalesce statement will be good with any warning ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ex&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table info as&lt;/P&gt;
&lt;P&gt;select coalesce(police, agreement_nbr) as agreement_nbr&lt;/P&gt;
&lt;P&gt;from source;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 15:40:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/making-proc-sql-create-table-info-as-using-a-call-execute/m-p/944103#M45236</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2024-09-16T15:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: making proc sql create table info as using a call execute</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/making-proc-sql-create-table-info-as-using-a-call-execute/m-p/944106#M45237</link>
      <description>&lt;P&gt;Only if both variables exist.&amp;nbsp; SQL statements will throw an error if you try to reference a variable that does not exist.&lt;/P&gt;
&lt;P&gt;Why are you using SQL?&amp;nbsp; Why not use normal SAS code?&amp;nbsp; A data step will create a variable for you if you reference it in the code and it was not already created by the source data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data info ;
  set source;
  agreement_nbr = coalesce(agreement_nbr,police);
  keep agreement_nbr;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the variables are ( or should be) character then you will need to use the COALESCEC() function instead.&amp;nbsp; In that case you might want to also use the CATS() function so it can handle datasets where POLICE or AGREEMENT_NBR are character.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data info ;
  set source;
  length newvar $40;
  newvar = coalescec(cats(agreement_nbr),cats(police));
  keep newvar;
  rname newvar=agreement_nbr;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Sep 2024 15:56:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/making-proc-sql-create-table-info-as-using-a-call-execute/m-p/944106#M45237</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-09-16T15:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: making proc sql create table info as using a call execute</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/making-proc-sql-create-table-info-as-using-a-call-execute/m-p/944117#M45238</link>
      <description>&lt;P&gt;Hello, I am using a proc sql because I need to make an inner join from a policies list table.&amp;nbsp; So, imagine that police is the variable name into some datasets and for other dataset it will be agreement_nbr, does the coalescec will work or not?&amp;nbsp; If not, what will be a work around solution.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 17:20:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/making-proc-sql-create-table-info-as-using-a-call-execute/m-p/944117#M45238</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2024-09-16T17:20:11Z</dc:date>
    </item>
    <item>
      <title>Re: making proc sql create table info as using a call execute</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/making-proc-sql-create-table-info-as-using-a-call-execute/m-p/944123#M45239</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76331"&gt;@alepage&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello, I am using a proc sql because I need to make an inner join from a policies list table.&amp;nbsp; So, imagine that police is the variable name into some datasets and for other dataset it will be agreement_nbr, does the coalescec will work or not?&amp;nbsp; If not, what will be a work around solution.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Know what variable to use before you write the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or write some code that can check and then generate the right code based on which variable(s) exist.&amp;nbsp; Perhaps a macro, but also you could do it with CALL EXECUTE() if you wanted, just like you mentioned in your topic.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 18:00:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/making-proc-sql-create-table-info-as-using-a-call-execute/m-p/944123#M45239</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-09-16T18:00:37Z</dc:date>
    </item>
  </channel>
</rss>

