<?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: how to keep or specify SAS date format with SQL natural join in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/how-to-keep-or-specify-SAS-date-format-with-SQL-natural-join/m-p/533326#M73825</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16896"&gt;@WendyT&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Ballardw and Reeza-&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I try not to specify columns except when it's absolutely necessary.&amp;nbsp; Either laziness or&amp;nbsp;efficiency, depending on the situation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ballardw, you now have me thinking that it's the *&amp;nbsp;rather than the natural join that is causing the loss of format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Reeza, the tip on&amp;nbsp;the feedback option is going to&amp;nbsp;be extremely&amp;nbsp;useful for me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks so much for your help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WendyT&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;My guess was actually that since Date was in both sets and&amp;nbsp;you did not specify which one goes into the output that&amp;nbsp;even though the format in both sets was the same that the algorithms used for the combination of Select * and Natural Join just kind of "lost" the format as neither bit was told which format to apply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do understand the use of * even though the diehard SQL programmers seem to shudder but I'm a SAS programmer first and Sql way down the list (my experience for SQL is mostly Proc Sql).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 06 Feb 2019 16:24:40 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-02-06T16:24:40Z</dc:date>
    <item>
      <title>how to keep or specify SAS date format with SQL natural join</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-keep-or-specify-SAS-date-format-with-SQL-natural-join/m-p/533084#M73805</link>
      <description>&lt;P&gt;Hello SAS folks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I use a natural join in SQL, the date format is lost, even if it's the same in both datasets.&amp;nbsp; Is there any easy way to keep or specify&amp;nbsp;the date format&amp;nbsp;without specifying&amp;nbsp;columns?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;tiny example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint ;
create table have
as select distinct *
from sashelp.pricedata (keep=date sale) 
natural join 
sashelp.prdsal3(keep=date state) 
where date between '01jan1998'D and '30may1998'D 
  and state='Florida' 
  and sale between 300 and 350 ;
quit ;

data want ; set have ;
format date mmddyy10. ;
run ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ideally, I&amp;nbsp;would like to have date come out as mmddyy10., so that I don't have to do&amp;nbsp;an additional step to create 'want'.&amp;nbsp; I'm running SAS 9.4M5 on Windows with a remote login, if that makes any difference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks so much for any help you can give me!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Wendy T&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 21:44:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-keep-or-specify-SAS-date-format-with-SQL-natural-join/m-p/533084#M73805</guid>
      <dc:creator>WendyT</dc:creator>
      <dc:date>2019-02-05T21:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep or specify SAS date format with SQL natural join</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-keep-or-specify-SAS-date-format-with-SQL-natural-join/m-p/533088#M73807</link>
      <description>&lt;P&gt;Being a bit more explicit about source and what to keep seems to work:&lt;/P&gt;
&lt;PRE&gt;proc sql noprint ;
create table work.have
as select distinct a.date, a.sale,b.state
from sashelp.pricedata (keep=date sale) &lt;FONT color="#0000ff"&gt;as a&lt;/FONT&gt; 
natural join 
sashelp.prdsal3(keep=date state)&lt;FONT color="#0000ff"&gt; as b
&lt;/FONT&gt;where a.date between '01jan1998'D and '30may1998'D 
  and state='Florida' 
  and sale between 300 and 350 ;
quit ;
&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Feb 2019 21:51:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-keep-or-specify-SAS-date-format-with-SQL-natural-join/m-p/533088#M73807</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-02-05T21:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep or specify SAS date format with SQL natural join</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-keep-or-specify-SAS-date-format-with-SQL-natural-join/m-p/533099#M73811</link>
      <description>If your tables are too big or you're just too lazy to list all fields (which I usually am), you can use the feedback option to have the code generated for you. &lt;BR /&gt;&lt;BR /&gt;Add the FEEDBACK option to your PROC SQL statement, get the code from the log and customize it there.</description>
      <pubDate>Tue, 05 Feb 2019 22:28:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-keep-or-specify-SAS-date-format-with-SQL-natural-join/m-p/533099#M73811</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-05T22:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep or specify SAS date format with SQL natural join</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-keep-or-specify-SAS-date-format-with-SQL-natural-join/m-p/533322#M73824</link>
      <description>&lt;P&gt;Ballardw and Reeza-&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I try not to specify columns except when it's absolutely necessary.&amp;nbsp; Either laziness or&amp;nbsp;efficiency, depending on the situation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ballardw, you now have me thinking that it's the *&amp;nbsp;rather than the natural join that is causing the loss of format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Reeza, the tip on&amp;nbsp;the feedback option is going to&amp;nbsp;be extremely&amp;nbsp;useful for me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks so much for your help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WendyT&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 16:16:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-keep-or-specify-SAS-date-format-with-SQL-natural-join/m-p/533322#M73824</guid>
      <dc:creator>WendyT</dc:creator>
      <dc:date>2019-02-06T16:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep or specify SAS date format with SQL natural join</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-keep-or-specify-SAS-date-format-with-SQL-natural-join/m-p/533326#M73825</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16896"&gt;@WendyT&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Ballardw and Reeza-&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I try not to specify columns except when it's absolutely necessary.&amp;nbsp; Either laziness or&amp;nbsp;efficiency, depending on the situation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ballardw, you now have me thinking that it's the *&amp;nbsp;rather than the natural join that is causing the loss of format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Reeza, the tip on&amp;nbsp;the feedback option is going to&amp;nbsp;be extremely&amp;nbsp;useful for me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks so much for your help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WendyT&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;My guess was actually that since Date was in both sets and&amp;nbsp;you did not specify which one goes into the output that&amp;nbsp;even though the format in both sets was the same that the algorithms used for the combination of Select * and Natural Join just kind of "lost" the format as neither bit was told which format to apply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do understand the use of * even though the diehard SQL programmers seem to shudder but I'm a SAS programmer first and Sql way down the list (my experience for SQL is mostly Proc Sql).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 16:24:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-keep-or-specify-SAS-date-format-with-SQL-natural-join/m-p/533326#M73825</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-02-06T16:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: how to keep or specify SAS date format with SQL natural join</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-keep-or-specify-SAS-date-format-with-SQL-natural-join/m-p/533363#M73826</link>
      <description>&lt;P&gt;I did a bit more reading, and&amp;nbsp;found that I could&amp;nbsp;add&amp;nbsp;ALTER TABLE to specify a format on the date variable. I'm sure that would make the SQL diehards shudder as well.&amp;nbsp; &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://communities.sas.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any other ideas?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks so much for your help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WendyT&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint ;
create table have
as select distinct *
from sashelp.pricedata (keep=date sale) 
natural join 
sashelp.prdsal3(keep=date state) 
where date between '01jan1998'D and '30may1998'D 
  and state='Florida' 
  and sale between 300 and 350 ;

alter table have 
modify date format=mmddyy10.  ;
quit ;

proc print data=have ; run ;
&lt;/CODE&gt;&lt;/PRE&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;
&lt;P&gt;&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;
&lt;P&gt;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 19:03:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-keep-or-specify-SAS-date-format-with-SQL-natural-join/m-p/533363#M73826</guid>
      <dc:creator>WendyT</dc:creator>
      <dc:date>2019-02-06T19:03:23Z</dc:date>
    </item>
  </channel>
</rss>

