<?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 sas sql into data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sas-sql-into-data-step/m-p/495994#M131044</link>
    <description>&lt;P&gt;Could someone familiar with sas change sql into data step.thank you for your attention&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 16 Sep 2018 01:31:51 GMT</pubDate>
    <dc:creator>Geo-</dc:creator>
    <dc:date>2018-09-16T01:31:51Z</dc:date>
    <item>
      <title>sas sql into data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-sql-into-data-step/m-p/495994#M131044</link>
      <description>&lt;P&gt;Could someone familiar with sas change sql into data step.thank you for your attention&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Sep 2018 01:31:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-sql-into-data-step/m-p/495994#M131044</guid>
      <dc:creator>Geo-</dc:creator>
      <dc:date>2018-09-16T01:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: sas sql into data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-sql-into-data-step/m-p/495995#M131045</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=tablea;
by a;
where "20150501" le batch_date le "20150519";
run;

proc sort data=tableb;
by a;
run;

data temp;
merge tablea(in=ina) tableb(in=inb);
by a;
if ina;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 16 Sep 2018 02:40:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-sql-into-data-step/m-p/495995#M131045</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2018-09-16T02:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: sas sql into data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-sql-into-data-step/m-p/495998#M131047</link>
      <description>&lt;P&gt;As a variant to what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12151"&gt;@Jagadishkatam&lt;/a&gt; posted.&lt;/P&gt;
&lt;P&gt;You will need to add a least a NODUPKEY to the 2nd sort in order to replicate the DISTINCT in the SQL sub-select.&lt;/P&gt;
&lt;P&gt;You will also need to control from which source data set same named columns get read.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=tablea out=_tablea;
  by a;
  where "20150501" le batch_date le "20150519";
run;

proc sort data=tableb(keep=a f city channel) out=_tableb nodupkey;
  by a f city channel;
run;

data want(drop=_:);
  merge 
    _tablea(
      in=ina 
      keep=a b c d e f g h
      rename=(e=_e g=_g h=_h)
      ) 
    _tableb(
      in=inb
      keep=a city channel
      )
    ;
  by a;
  if ina;

  length e g h $8;
  e=put(datepart(_e),YYMMDDN8.);
  g=put(datepart(_g),YYMMDDN8.);
  h=put(datepart(_h),YYMMDDN8.);

  if missing(f) then f=e;

run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;N.B: You haven't provided sample data so above code is not tested.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Sep 2018 03:42:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-sql-into-data-step/m-p/495998#M131047</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-09-16T03:42:27Z</dc:date>
    </item>
  </channel>
</rss>

