<?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: base sas to proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/base-sas-to-proc-sql/m-p/452890#M114346</link>
    <description>&lt;P&gt;Note that a data step merge does things with variables common to both sets depending on the order they appear on the merge statement that you will have to explicitly code in sql for &lt;STRONG&gt;every single variable&lt;/STRONG&gt; to get the same result from proc sql.&lt;/P&gt;</description>
    <pubDate>Tue, 10 Apr 2018 16:48:50 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-04-10T16:48:50Z</dc:date>
    <item>
      <title>base sas to proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/base-sas-to-proc-sql/m-p/452737#M114281</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I want to write base sas code to proc sql.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
merge  test (in=a) name (in=b);
by id;
if a=b then do;
	%all(test);
end;
if a then output;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;SS&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2018 08:19:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/base-sas-to-proc-sql/m-p/452737#M114281</guid>
      <dc:creator>sathya66</dc:creator>
      <dc:date>2018-04-10T08:19:44Z</dc:date>
    </item>
    <item>
      <title>Re: base sas to proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/base-sas-to-proc-sql/m-p/452740#M114284</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/93352"&gt;@sathya66&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I want to write base sas code to proc sql.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
merge  test (in=a) name (in=b);
by id;
if a=b then do;
	%all(test);
end;
if a then output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;SS&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since your macro contains data step code, this will not be possible.&lt;/P&gt;
&lt;P&gt;You will also have to rewrite your macro; to see if your macro code can be converted to SQL, we will need to see it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your data step code works, there is no reason to convert it to SQL.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2018 08:31:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/base-sas-to-proc-sql/m-p/452740#M114284</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-10T08:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: base sas to proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/base-sas-to-proc-sql/m-p/452746#M114290</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;Kurt,&lt;/P&gt;&lt;P&gt;My base sas code is working fine but I want to make it dynamic and I don't want to sort the data because by variable name&amp;nbsp;is different in other tables (ex: ID, in other table this ID is "empID") so I&amp;nbsp;am looking&amp;nbsp;in proc sql.&lt;/P&gt;&lt;P&gt;my all macro&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test(dsname,varname);
%if %varexist(&amp;amp;dsname,&amp;amp;varname) %then %do;
 	%if %getvartype(&amp;amp;dsname,&amp;amp;varname)=C %then %do;
		if &amp;amp;varname ne ' ' then
			&amp;amp;varname = "xxxxx";

	%end;
	%else %if %getvartype(&amp;amp;dsname,&amp;amp;varname)=N %then %do;
	
		if &amp;amp;varname ne .   then
			&amp;amp;varname =11111;

	%end;
	%end;
%mend test;

%macro all(dsname);
%test(&amp;amp;dsname,Name);
%test(&amp;amp;dsname,forename);
%test(&amp;amp;dsname,sal);
%mend all;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SS&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2018 08:52:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/base-sas-to-proc-sql/m-p/452746#M114290</guid>
      <dc:creator>sathya66</dc:creator>
      <dc:date>2018-04-10T08:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: base sas to proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/base-sas-to-proc-sql/m-p/452747#M114291</link>
      <description>&lt;P&gt;So what is it your actually trying to achieve with this code?&amp;nbsp; Follow the guidance on posting new questions: Provide test data in the form of a datastep so we have something to run, and what you want out at the end.&amp;nbsp; It appears to me that you have a convoluted process to fill some missing data in with defaults.&amp;nbsp; You do not need any of this, you could just merge and use arrays for example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In SQL, you can do:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table want as
  select a.var1,&lt;BR /&gt;         a.var2,&lt;BR /&gt;         b.var3,&lt;BR /&gt;         case when coalesce(a.id,b.empid)=" " then "xxxx" else coalesce(a.id,b.empid) end as id&lt;BR /&gt;  from   test a&lt;BR /&gt;  left join name b&lt;BR /&gt;  on     a.id=b.empid;&lt;BR /&gt;quit;&lt;/PRE&gt;
&lt;P&gt;Of course that is just a code snippet and there are lots of other bits, question is is it worth it as you wont get anthing different to the code you already have, and if you update then its far simpler.&amp;nbsp; Also note that using proc sql will not solve the sort, as it just does the sort internally.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;data test;&lt;BR /&gt; merge test (in=a) name (in=b);&lt;BR /&gt; by id;&lt;BR /&gt; array n _numeric_;&lt;BR /&gt; array c _character_;&lt;BR /&gt; if a=b then do;&lt;BR /&gt;   do over n;&lt;BR /&gt;     if n=. then n=1111;&lt;BR /&gt;   end;&lt;BR /&gt;   do over c;&lt;BR /&gt;     if c=" " then c="xxxx";&lt;BR /&gt;   end;&lt;BR /&gt; end;&lt;BR /&gt; if a then output;&lt;BR /&gt;run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Apr 2018 09:03:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/base-sas-to-proc-sql/m-p/452747#M114291</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-10T09:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: base sas to proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/base-sas-to-proc-sql/m-p/452751#M114293</link>
      <description>&lt;P&gt;You will have to create a SQL step first that does what you want for a single dataset. Once that works, you can start to make the code dynamic.&lt;/P&gt;
&lt;P&gt;Changing only one or several variables while leaving the others untouched is done with the update statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table class as select * from sashelp.class;
update class set name = 'XXXX', age = 1111;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You will need to create a SQL-suitable version of your macro that inserts the wanted variables into the set part.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2018 09:15:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/base-sas-to-proc-sql/m-p/452751#M114293</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-10T09:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: base sas to proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/base-sas-to-proc-sql/m-p/452890#M114346</link>
      <description>&lt;P&gt;Note that a data step merge does things with variables common to both sets depending on the order they appear on the merge statement that you will have to explicitly code in sql for &lt;STRONG&gt;every single variable&lt;/STRONG&gt; to get the same result from proc sql.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2018 16:48:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/base-sas-to-proc-sql/m-p/452890#M114346</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-04-10T16:48:50Z</dc:date>
    </item>
  </channel>
</rss>

