<?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 SAS Merging and Creating New Variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Merging-and-Creating-New-Variables/m-p/174650#M44856</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to merge two data sets and then create new variables from these data sets. In my library, I have two data sets (cross1 and long1) with the common variable MEDRNO. I'm trying to merge them and create two new variables (change_dilation and change_time). For these new variables, i want to take the difference between the first observation of dilation and all other observations of dilation. The same goes with change_time. However, I'm not getting any observations in my output. Any idea what I am doing wrong? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*question 1;&lt;/P&gt;&lt;P&gt;libname Hwk4 'C:\Users\USERABC\Desktop\Assignment 4';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;*question 2a;&lt;/P&gt;&lt;P&gt;proc sort data=hwk4.cross1;by MEDRNO;&lt;/P&gt;&lt;P&gt;proc sort data=hwk4.long1;by MEDRNO;&lt;/P&gt;&lt;P&gt;data merged;&lt;/P&gt;&lt;P&gt;merge hwk4.cross1 hwk4.long1;&lt;/P&gt;&lt;P&gt;by MEDRNO;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*question 2b;&lt;/P&gt;&lt;P&gt;data hwk4;&lt;/P&gt;&lt;P&gt;if first.MEDRNO = 1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; base_dil = DILATION;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t0 = time;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;retain base_dil t0;&lt;/P&gt;&lt;P&gt;change_dilation = DILATION - base_dil;&lt;/P&gt;&lt;P&gt;change_time = time - t0;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 09 Apr 2014 22:19:56 GMT</pubDate>
    <dc:creator>kernsaf</dc:creator>
    <dc:date>2014-04-09T22:19:56Z</dc:date>
    <item>
      <title>SAS Merging and Creating New Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Merging-and-Creating-New-Variables/m-p/174650#M44856</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to merge two data sets and then create new variables from these data sets. In my library, I have two data sets (cross1 and long1) with the common variable MEDRNO. I'm trying to merge them and create two new variables (change_dilation and change_time). For these new variables, i want to take the difference between the first observation of dilation and all other observations of dilation. The same goes with change_time. However, I'm not getting any observations in my output. Any idea what I am doing wrong? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*question 1;&lt;/P&gt;&lt;P&gt;libname Hwk4 'C:\Users\USERABC\Desktop\Assignment 4';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;*question 2a;&lt;/P&gt;&lt;P&gt;proc sort data=hwk4.cross1;by MEDRNO;&lt;/P&gt;&lt;P&gt;proc sort data=hwk4.long1;by MEDRNO;&lt;/P&gt;&lt;P&gt;data merged;&lt;/P&gt;&lt;P&gt;merge hwk4.cross1 hwk4.long1;&lt;/P&gt;&lt;P&gt;by MEDRNO;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*question 2b;&lt;/P&gt;&lt;P&gt;data hwk4;&lt;/P&gt;&lt;P&gt;if first.MEDRNO = 1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; base_dil = DILATION;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t0 = time;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;retain base_dil t0;&lt;/P&gt;&lt;P&gt;change_dilation = DILATION - base_dil;&lt;/P&gt;&lt;P&gt;change_time = time - t0;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Apr 2014 22:19:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Merging-and-Creating-New-Variables/m-p/174650#M44856</guid>
      <dc:creator>kernsaf</dc:creator>
      <dc:date>2014-04-09T22:19:56Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Merging and Creating New Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Merging-and-Creating-New-Variables/m-p/174651#M44857</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What does the log say for starters.&lt;/P&gt;&lt;P&gt;For question 2b you dont have a set statement so you're not referring to any data set.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Apr 2014 22:23:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Merging-and-Creating-New-Variables/m-p/174651#M44857</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-04-09T22:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Merging and Creating New Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Merging-and-Creating-New-Variables/m-p/174652#M44858</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Some sample data would help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 04:30:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Merging-and-Creating-New-Variables/m-p/174652#M44858</guid>
      <dc:creator>SKK</dc:creator>
      <dc:date>2014-04-10T04:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Merging and Creating New Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Merging-and-Creating-New-Variables/m-p/174653#M44859</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For question 2b use set statement and use retain statement before set statement and try if still find problem then elobrate you issue using some dummy data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 05:37:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Merging-and-Creating-New-Variables/m-p/174653#M44859</guid>
      <dc:creator>Chrishi</dc:creator>
      <dc:date>2014-04-10T05:37:40Z</dc:date>
    </item>
  </channel>
</rss>

