<?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: adding a variable from one data set to another in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/adding-a-variable-from-one-data-set-to-another/m-p/725820#M225520</link>
    <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;, thank you! It did work!</description>
    <pubDate>Fri, 12 Mar 2021 15:58:29 GMT</pubDate>
    <dc:creator>NinaWestern</dc:creator>
    <dc:date>2021-03-12T15:58:29Z</dc:date>
    <item>
      <title>adding a variable from one data set to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/adding-a-variable-from-one-data-set-to-another/m-p/725812#M225516</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;
&lt;P&gt;I would appreciate your input.&lt;/P&gt;
&lt;P&gt;I need to add a variable from one data set to another one. They are both sorted by the key variable. I used a proc sql syntax posted here in another thread, but keep receiving error messages.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DDini- main data set&lt;/P&gt;
&lt;P&gt;DD2- the second data set, from which I need only one variable, named ib14_new.&lt;/P&gt;
&lt;P&gt;Here is my syntax:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table DDm&lt;/P&gt;
&lt;P&gt;as select work.DDini.*, work.DD2.ib14_new&lt;/P&gt;
&lt;P&gt;from work.DDini left join work.DD2&lt;/P&gt;
&lt;P&gt;on work.DDini.crn= work.DD2.crn;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The error message is attached.&lt;/P&gt;
&lt;P&gt;Any help resolving this is very appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Mar 2021 15:29:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/adding-a-variable-from-one-data-set-to-another/m-p/725812#M225516</guid>
      <dc:creator>NinaWestern</dc:creator>
      <dc:date>2021-03-12T15:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: adding a variable from one data set to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/adding-a-variable-from-one-data-set-to-another/m-p/725816#M225518</link>
      <description>&lt;P&gt;Because of the several ways that SAS uses a dot in constructing various items in syntax you can't have more than one . (other than macro variables) to&amp;nbsp; reference data set and variable names. So you need to create an alias that means the library.dataset combination.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table DDm
   as select A.*, B.ib14_new
   from work.DDini as A left join work.DD2 as B
   on A.crn= B.crn;
quit;&lt;/PRE&gt;
&lt;P&gt;I explicitly use "as A" to set the alias but simple "work.DDini A" would work.&lt;/P&gt;
&lt;P&gt;Of course the default library for data sets with a single level name means you can probably drop the "work." everywhere&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW it is best on this forum to paste text such as LOG entries or code into a text box opened on the forum with the &amp;lt;/&amp;gt; icon to preserve formatting.&lt;/P&gt;
&lt;P&gt;Many won't open DOCX, or several other file formats from unknown users either by choice or organization policy.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Mar 2021 15:44:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/adding-a-variable-from-one-data-set-to-another/m-p/725816#M225518</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-03-12T15:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: adding a variable from one data set to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/adding-a-variable-from-one-data-set-to-another/m-p/725820#M225520</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;, thank you! It did work!</description>
      <pubDate>Fri, 12 Mar 2021 15:58:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/adding-a-variable-from-one-data-set-to-another/m-p/725820#M225520</guid>
      <dc:creator>NinaWestern</dc:creator>
      <dc:date>2021-03-12T15:58:29Z</dc:date>
    </item>
  </channel>
</rss>

