<?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 sql into data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sql-into-data-step/m-p/492871#M129620</link>
    <description>&lt;P&gt;this maybe simple to SAS user.Someone&amp;nbsp; please kindly change the sql code into data step&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
create table temp as
select A.a,A.b,A.c,A.d,
put(datepart(A.e),YYMMDDN8.) as e,
case when A.f is null then calculated e
else A.f end as f,
put(datepart(A.g),YYMMDDN8.) as g,
put(datepart(A.h),YYMMDDN8.) as h,
B.city,
B.channel
from tableA(where=("20150501" le batch_date le "20150519")) A
left join (select distinct a,f,city,channel from tableB) B
on A.a=B.a
order by 1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 06 Sep 2018 03:49:32 GMT</pubDate>
    <dc:creator>Geo-</dc:creator>
    <dc:date>2018-09-06T03:49:32Z</dc:date>
    <item>
      <title>sql into data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sql-into-data-step/m-p/492871#M129620</link>
      <description>&lt;P&gt;this maybe simple to SAS user.Someone&amp;nbsp; please kindly change the sql code into data step&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
create table temp as
select A.a,A.b,A.c,A.d,
put(datepart(A.e),YYMMDDN8.) as e,
case when A.f is null then calculated e
else A.f end as f,
put(datepart(A.g),YYMMDDN8.) as g,
put(datepart(A.h),YYMMDDN8.) as h,
B.city,
B.channel
from tableA(where=("20150501" le batch_date le "20150519")) A
left join (select distinct a,f,city,channel from tableB) B
on A.a=B.a
order by 1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Sep 2018 03:49:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sql-into-data-step/m-p/492871#M129620</guid>
      <dc:creator>Geo-</dc:creator>
      <dc:date>2018-09-06T03:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: sql into data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sql-into-data-step/m-p/492875#M129621</link>
      <description>&lt;P&gt;This can be done by sorting tableA and tableB and then merging both tables by variable a. &lt;U&gt;But only if&lt;/U&gt; variable a is unique key in at least one of the tables. Otherwise, the datastep merge operation will not be the same as a SQL join.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 04:30:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sql-into-data-step/m-p/492875#M129621</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-09-06T04:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: sql into data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sql-into-data-step/m-p/492884#M129624</link>
      <description>Why?</description>
      <pubDate>Thu, 06 Sep 2018 06:17:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sql-into-data-step/m-p/492884#M129624</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2018-09-06T06:17:09Z</dc:date>
    </item>
    <item>
      <title>Re: sql into data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sql-into-data-step/m-p/493054#M129690</link>
      <description>&lt;P&gt;As an aside to the specific question, you may want to consider using actual SAS date values instead of character variables masquerading as dates. Between the date functions and date formats you can do a lot of manipulation and report grouping without adding variables with actual dates that just are not possible with character values.&lt;/P&gt;
&lt;P&gt;Also ranges of character values such as you use such as in&lt;/P&gt;
&lt;PRE&gt;where=("20150501" le batch_date le "20150519")&lt;/PRE&gt;
&lt;P&gt;can be very problematic if you have unexpected (possibly erroneous ) values for the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example&lt;/P&gt;
&lt;PRE&gt;data example;
   batch_date='201505110';
   if "20150501" le batch_date le "20150519" then put "in range";
   else put "out of range";
run;&lt;/PRE&gt;
&lt;P&gt;Which shows that '201505110' is inside the range when using character comparisons.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 15:04:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sql-into-data-step/m-p/493054#M129690</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-09-06T15:04:38Z</dc:date>
    </item>
  </channel>
</rss>

