<?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 Append some codes in one proc sql statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Append-some-codes-in-one-proc-sql-statement/m-p/252758#M48038</link>
    <description>&lt;P&gt;I want to append these codes in one proc sql statement. Is that possible?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is that possible with union or union corr?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;PROC SQL; CREATE TABLE SGBSTDN AS&lt;BR /&gt;SELECT DISTINCT SGBSTDN_PIDM AS PIDM,&lt;BR /&gt; 'Student' as StatusStudent&lt;BR /&gt;FROM STG.SGBSTDN&lt;BR /&gt;ORDER BY PIDM&lt;BR /&gt;;QUIT;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SQL; CREATE TABLE SARADAP AS&lt;BR /&gt;SELECT DISTINCT SARADAP_PIDM AS PIDM,&lt;BR /&gt; 'Applicant' as StatusApplicant&lt;BR /&gt;FROM STG.SARADAP&lt;BR /&gt;ORDER BY PIDM&lt;BR /&gt;;QUIT;&lt;/P&gt;
&lt;P&gt;data STUDENT_PIDM;&lt;BR /&gt;merge SGBSTDN SARADAP ;&lt;BR /&gt;by pidm;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data student_pidm2;&lt;BR /&gt;set student_pidm;&lt;BR /&gt;if StatusStudent='' then StatusStudent='Applicant';&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table&amp;nbsp;STUDENT as&lt;BR /&gt;select distinct pidm,&lt;BR /&gt; StatusStudent,&lt;BR /&gt;case &lt;BR /&gt; when b.Spbpers_sex IS NULL then "N" &lt;BR /&gt; when b.Spbpers_sex ='N' then "N"&lt;/P&gt;
&lt;P&gt;when b.Spbpers_sex ='F' then "F" &lt;BR /&gt; when b.Spbpers_sex ='M' then "M"&lt;BR /&gt; END AS GENDER&lt;/P&gt;
&lt;P&gt;from work.student_pidm2 as a left join stg.spbpers as b &lt;BR /&gt; on b.spbpers_pidm=a.pidm ;&lt;BR /&gt; quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please let me know if it is possible?&lt;/P&gt;</description>
    <pubDate>Fri, 26 Feb 2016 18:02:37 GMT</pubDate>
    <dc:creator>user24</dc:creator>
    <dc:date>2016-02-26T18:02:37Z</dc:date>
    <item>
      <title>Append some codes in one proc sql statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-some-codes-in-one-proc-sql-statement/m-p/252758#M48038</link>
      <description>&lt;P&gt;I want to append these codes in one proc sql statement. Is that possible?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is that possible with union or union corr?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;PROC SQL; CREATE TABLE SGBSTDN AS&lt;BR /&gt;SELECT DISTINCT SGBSTDN_PIDM AS PIDM,&lt;BR /&gt; 'Student' as StatusStudent&lt;BR /&gt;FROM STG.SGBSTDN&lt;BR /&gt;ORDER BY PIDM&lt;BR /&gt;;QUIT;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SQL; CREATE TABLE SARADAP AS&lt;BR /&gt;SELECT DISTINCT SARADAP_PIDM AS PIDM,&lt;BR /&gt; 'Applicant' as StatusApplicant&lt;BR /&gt;FROM STG.SARADAP&lt;BR /&gt;ORDER BY PIDM&lt;BR /&gt;;QUIT;&lt;/P&gt;
&lt;P&gt;data STUDENT_PIDM;&lt;BR /&gt;merge SGBSTDN SARADAP ;&lt;BR /&gt;by pidm;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data student_pidm2;&lt;BR /&gt;set student_pidm;&lt;BR /&gt;if StatusStudent='' then StatusStudent='Applicant';&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table&amp;nbsp;STUDENT as&lt;BR /&gt;select distinct pidm,&lt;BR /&gt; StatusStudent,&lt;BR /&gt;case &lt;BR /&gt; when b.Spbpers_sex IS NULL then "N" &lt;BR /&gt; when b.Spbpers_sex ='N' then "N"&lt;/P&gt;
&lt;P&gt;when b.Spbpers_sex ='F' then "F" &lt;BR /&gt; when b.Spbpers_sex ='M' then "M"&lt;BR /&gt; END AS GENDER&lt;/P&gt;
&lt;P&gt;from work.student_pidm2 as a left join stg.spbpers as b &lt;BR /&gt; on b.spbpers_pidm=a.pidm ;&lt;BR /&gt; quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please let me know if it is possible?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Feb 2016 18:02:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-some-codes-in-one-proc-sql-statement/m-p/252758#M48038</guid>
      <dc:creator>user24</dc:creator>
      <dc:date>2016-02-26T18:02:37Z</dc:date>
    </item>
    <item>
      <title>Re: Make one code from bunch of them with union sql sel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-some-codes-in-one-proc-sql-statement/m-p/252766#M48040</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/44102"&gt;@user24&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I have a bunch of codes. I want to make them together in one sql sel code&lt;/P&gt;
&lt;P&gt;Is that possible with union or union corr?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What are you trying to do? Combine all your 3 SQL to one step?&lt;/P&gt;
&lt;P&gt;Append all the tables together that you created?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Feb 2016 17:26:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-some-codes-in-one-proc-sql-statement/m-p/252766#M48040</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-26T17:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: Make one code from bunch of them with union sql sel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-some-codes-in-one-proc-sql-statement/m-p/252767#M48041</link>
      <description>&lt;P&gt;Yes, i want to append them in one step. Sorry if i couldn't explain&lt;/P&gt;</description>
      <pubDate>Fri, 26 Feb 2016 17:46:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-some-codes-in-one-proc-sql-statement/m-p/252767#M48041</guid>
      <dc:creator>user24</dc:creator>
      <dc:date>2016-02-26T17:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: Make one code from bunch of them with union sql sel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-some-codes-in-one-proc-sql-statement/m-p/252840#M48063</link>
      <description>&lt;P&gt;Over time, I have come to the conclusion that having several simple steps instead of one complicated step is easier to maintain and usually more performant. This is particularly true when working with PROC SQL.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Feb 2016 21:44:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-some-codes-in-one-proc-sql-statement/m-p/252840#M48063</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-02-26T21:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: Append some codes in one proc sql statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-some-codes-in-one-proc-sql-statement/m-p/252858#M48073</link>
      <description>I think that you could put the last data step and the last SQL in one SQL. &lt;BR /&gt;Replace your IF and CASE statements with the coalesce() function to make your code easier and with less hard coding.</description>
      <pubDate>Fri, 26 Feb 2016 22:55:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-some-codes-in-one-proc-sql-statement/m-p/252858#M48073</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-02-26T22:55:35Z</dc:date>
    </item>
  </channel>
</rss>

