<?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: Append code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Append-code/m-p/252814#M48057</link>
    <description>&lt;P&gt;You can use COALESCE() to get the applicant/student status:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  coalescec(statusstudent, StudentApplicant) as variable_name&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To remove the records, ie take the Student over Applicant you'll have to write some additional logic. Personally, I don't prefer to have long SQL codes for multiple calculations because it gets unwieldy and hard to debug. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A data step would be relatively easy to get the first or last record of multiple ID's.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 26 Feb 2016 20:48:44 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-02-26T20:48:44Z</dc:date>
    <item>
      <title>Append code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-code/m-p/252782#M48044</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a code as below.&lt;/P&gt;
&lt;P&gt;But my output shows like same pidm twice with student and applicant . I want to shows if it is duplicate take the only student.&lt;/P&gt;
&lt;P&gt;So my output as below:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;pidm &amp;nbsp; &amp;nbsp; &amp;nbsp;statusstudent &amp;nbsp; &amp;nbsp; gender &amp;nbsp; &amp;nbsp; &amp;nbsp;StudentApplicant&lt;/P&gt;
&lt;P&gt;102 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Student &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; F&lt;/P&gt;
&lt;P&gt;108 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Student &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; M&amp;nbsp;&lt;/P&gt;
&lt;P&gt;108 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; M &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Applicant&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;pidm &amp;nbsp; &amp;nbsp; &amp;nbsp;statusstudent &amp;nbsp; &amp;nbsp; gender &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;102 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Student &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; F&lt;/P&gt;
&lt;P&gt;108 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Applicant &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;M&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But i want to do this inside this code i wrote. Not a saperate code. I need to append this code? Is that possible or not? I will delete my other post. Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL; &lt;BR /&gt;CREATE TABLE SGBSTDN AS
SELECT DISTINCT a.SGBSTDN_PIDM AS PIDM,
'Student' as StatusStudent,
case 
when b.Spbpers_sex IS NULL then "N" 
when b.Spbpers_sex ='F' then "F" 
when b.Spbpers_sex ='M' then "M"
end as gender 
FROM STG.SGBSTDN as a left join stg.spbpers as b 
on b.spbpers_pidm=a.SGBSTDN_PIDM 
outer union corr
SELECT DISTINCT d.SARADAP_PIDM AS PIDM,
'Applicant' as StatusApplicant,
case 
when c.Spbpers_sex IS NULL then "N" 
when c.Spbpers_sex ='F' then "F" 
when c.Spbpers_sex ='M' then "M"
end as gender 
FROM STG.SARADAP as d left join stg.spbpers as c
on c.spbpers_pidm=d.SARADAP_PIDM
ORDER BY PIDM
;QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Feb 2016 20:44:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-code/m-p/252782#M48044</guid>
      <dc:creator>user24</dc:creator>
      <dc:date>2016-02-26T20:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: Append code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-code/m-p/252814#M48057</link>
      <description>&lt;P&gt;You can use COALESCE() to get the applicant/student status:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  coalescec(statusstudent, StudentApplicant) as variable_name&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To remove the records, ie take the Student over Applicant you'll have to write some additional logic. Personally, I don't prefer to have long SQL codes for multiple calculations because it gets unwieldy and hard to debug. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A data step would be relatively easy to get the first or last record of multiple ID's.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Feb 2016 20:48:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-code/m-p/252814#M48057</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-26T20:48:44Z</dc:date>
    </item>
  </channel>
</rss>

