<?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 Adding new columns in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Adding-new-columns/m-p/60459#M17129</link>
    <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I have a situation like the following&lt;BR /&gt;
&lt;BR /&gt;
example:&lt;BR /&gt;
&lt;BR /&gt;
doctor&lt;BR /&gt;
-----------------------------------&lt;BR /&gt;
specialtykey doctorname&lt;BR /&gt;
1                   john&lt;BR /&gt;
2                   Sam&lt;BR /&gt;
3                    Mary&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
doctor specialty table&lt;BR /&gt;
----------------------------&lt;BR /&gt;
specialtykey  specialty&lt;BR /&gt;
1                    ENT&lt;BR /&gt;
1                       Cardiologist&lt;BR /&gt;
1                     General&lt;BR /&gt;
2                      eyes&lt;BR /&gt;
2                       family&lt;BR /&gt;
3                       Gastro&lt;BR /&gt;
&lt;BR /&gt;
My output dataset should look like this&lt;BR /&gt;
&lt;BR /&gt;
Final&lt;BR /&gt;
----------&lt;BR /&gt;
doctorname specialty1 specialty2    specialty3&lt;BR /&gt;
john             ENT         Cardiologist  General&lt;BR /&gt;
sam              eyes        family &lt;BR /&gt;
mary             Gastro&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Please help</description>
    <pubDate>Sat, 20 Feb 2010 00:18:32 GMT</pubDate>
    <dc:creator>ren2010</dc:creator>
    <dc:date>2010-02-20T00:18:32Z</dc:date>
    <item>
      <title>Adding new columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-new-columns/m-p/60459#M17129</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I have a situation like the following&lt;BR /&gt;
&lt;BR /&gt;
example:&lt;BR /&gt;
&lt;BR /&gt;
doctor&lt;BR /&gt;
-----------------------------------&lt;BR /&gt;
specialtykey doctorname&lt;BR /&gt;
1                   john&lt;BR /&gt;
2                   Sam&lt;BR /&gt;
3                    Mary&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
doctor specialty table&lt;BR /&gt;
----------------------------&lt;BR /&gt;
specialtykey  specialty&lt;BR /&gt;
1                    ENT&lt;BR /&gt;
1                       Cardiologist&lt;BR /&gt;
1                     General&lt;BR /&gt;
2                      eyes&lt;BR /&gt;
2                       family&lt;BR /&gt;
3                       Gastro&lt;BR /&gt;
&lt;BR /&gt;
My output dataset should look like this&lt;BR /&gt;
&lt;BR /&gt;
Final&lt;BR /&gt;
----------&lt;BR /&gt;
doctorname specialty1 specialty2    specialty3&lt;BR /&gt;
john             ENT         Cardiologist  General&lt;BR /&gt;
sam              eyes        family &lt;BR /&gt;
mary             Gastro&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Please help</description>
      <pubDate>Sat, 20 Feb 2010 00:18:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-new-columns/m-p/60459#M17129</guid>
      <dc:creator>ren2010</dc:creator>
      <dc:date>2010-02-20T00:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: Adding new columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-new-columns/m-p/60460#M17130</link>
      <description>Hope this was for a 'real' situation and not only to do someones homework...&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick&lt;BR /&gt;
&lt;BR /&gt;
data doctor;&lt;BR /&gt;
input specialtykey doctorname $30.;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 john&lt;BR /&gt;
2 Sam&lt;BR /&gt;
3 Mary&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data specialty;&lt;BR /&gt;
input specialtykey specialty $30.;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 ENT&lt;BR /&gt;
1 Cardiologist&lt;BR /&gt;
1 General&lt;BR /&gt;
2 eyes&lt;BR /&gt;
2 family&lt;BR /&gt;
3 Gastro&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
  create view DoctorSpecialty as&lt;BR /&gt;
    select d.*,s.specialty&lt;BR /&gt;
      from doctor as d left join specialty as s&lt;BR /&gt;
        on d.specialtykey=s.specialtykey&lt;BR /&gt;
      order by doctorname&lt;BR /&gt;
  ;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
proc transpose data=DoctorSpecialty out=want(drop=_name_) prefix=Specialty;&lt;BR /&gt;
  by doctorname;&lt;BR /&gt;
  var specialty;&lt;BR /&gt;
run;

Looking at the two tables the data model looks kind of weird to me. I would expect the key to be "doctorkey" and this key to be the foreign key in specialty.&lt;BR /&gt;
&lt;BR /&gt;
If this would be normalised then I would expect to see the following tables:&lt;BR /&gt;
Doctor {doctorkey, name}&lt;BR /&gt;
Specialty {specialtykey,specialty}&lt;BR /&gt;
DoctorSpecialty {doctorkey,specialtykey}</description>
      <pubDate>Sat, 20 Feb 2010 13:42:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-new-columns/m-p/60460#M17130</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-02-20T13:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: Adding new columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-new-columns/m-p/60461#M17131</link>
      <description>Thanks So Much.</description>
      <pubDate>Sun, 21 Feb 2010 18:22:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-new-columns/m-p/60461#M17131</guid>
      <dc:creator>ren2010</dc:creator>
      <dc:date>2010-02-21T18:22:38Z</dc:date>
    </item>
  </channel>
</rss>

