<?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: how to calculate differences from a baseline value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-differences-from-a-baseline-value/m-p/131952#M26891</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks to everyone for their response! I'll give them a try.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 12 Jul 2013 15:30:41 GMT</pubDate>
    <dc:creator>chucs</dc:creator>
    <dc:date>2013-07-12T15:30:41Z</dc:date>
    <item>
      <title>how to calculate differences from a baseline value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-differences-from-a-baseline-value/m-p/131948#M26887</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a data set created with the following code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;input id $ dxday caetype $;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;01 1890 NONSP&lt;/P&gt;&lt;P&gt;01 2120 INFL&lt;/P&gt;&lt;P&gt;01 2128 INFL&lt;/P&gt;&lt;P&gt;01 2135 INFL&lt;/P&gt;&lt;P&gt;01 2137 NONSP&lt;/P&gt;&lt;P&gt;02 -775 INFL&lt;/P&gt;&lt;P&gt;02 -569 NONSP&lt;/P&gt;&lt;P&gt;03 3020 ARR&lt;/P&gt;&lt;P&gt;03 3026 NONSP&lt;/P&gt;&lt;P&gt;03 3027 NONSP&lt;/P&gt;&lt;P&gt;03 3175 INFL&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The 3 variables denote patient ID number, number of days the patient experienced a cardiac adverse event (CAE) relative to a certain vaccination, and type of CAE. I'm trying to calculate differences in the number of days from a baseline value for each patient, where the baseline value is the first occurrence of a CAE with type 'INFL'. So, for ID 01, the first INFL CAE occurs at the 2nd observation (dxday=2120); for ID 02, the first INFL CAE occurs at the 1st observation (dxday=-775); and for ID 03 the first INFL CAE occurs at the last observation (dxday=3175). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I'd like to do is to create a difference variable (DIFF) that calculates time differences based on the correctly identified baseline time value for each patient. So, what I'd like to end up with is a data set that looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="297" style="border: 1px solid rgb(0, 0, 0); width: 308px; height: 245px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;id&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;dxday&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;caetype&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;DIFF&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;01&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: right;"&gt;1890&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;NONSP&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: right;"&gt;-230&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;01&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: right;"&gt;2120&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;INFL&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: right;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;01&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: right;"&gt;2128&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;INFL&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: right;"&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;01&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: right;"&gt;2135&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;INFL&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: right;"&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;01&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: right;"&gt;2137&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;NONSP&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: right;"&gt;17&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;02&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: right;"&gt;-775&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;INFL&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: right;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;02&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: right;"&gt;-569&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;NONSP&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: right;"&gt;206&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;03&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: right;"&gt;3020&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;ARR&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: right;"&gt;-155&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;03&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: right;"&gt;3026&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;NONSP&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: right;"&gt;-149&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;03&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: right;"&gt;3027&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;NONSP&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: right;"&gt;-148&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;03&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: right;"&gt;3175&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;INFL&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: right;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone provide any insight on how to do this? Thanks so much!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;chucsp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 15:28:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-differences-from-a-baseline-value/m-p/131948#M26887</guid>
      <dc:creator>chucs</dc:creator>
      <dc:date>2013-07-11T15:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate differences from a baseline value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-differences-from-a-baseline-value/m-p/131949#M26888</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First get a dataset that keeps the first value of caetype per each ID, along with the dxday, then re-merge that dataset onto the original and find the difference. The following code will do the trick rather easily.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: You did not specify how to define the "First" value of each INFL per id, so I am going to assume the base order of the data (aka the variable _n_) is the correct variable to find the "first" value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #0000e6; font-size: 10pt; font-family: Consolas;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; font-size: 10pt;"&gt; &lt;SPAN style="color: black;"&gt;test1&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000e6; font-family: Consolas; font-size: 10pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; font-size: 10pt;"&gt; &lt;SPAN style="color: black;"&gt;test&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;ordervar=_N_&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000e6; font-family: Consolas; font-size: 10pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; font-size: 10pt;"&gt; &lt;SPAN style="color: black;"&gt;caetype=&lt;/SPAN&gt;&lt;SPAN style="color: purple;"&gt;'INFL'&lt;/SPAN&gt;&lt;SPAN style="color: black;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #0000e6; font-size: 10pt; font-family: Consolas;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000e6; font-size: 10pt;"&gt;sort&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000e6; font-size: 10pt;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;=test1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;by id ordervar;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000e6; font-size: 10pt;"&gt;run&lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #0000e6; font-size: 10pt; font-family: Consolas;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; font-size: 10pt;"&gt; &lt;SPAN style="color: black;"&gt;joinvalues(drop=ordervar caetype)&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000e6; font-family: Consolas; font-size: 10pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; font-size: 10pt;"&gt; &lt;SPAN style="color: black;"&gt;test1&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000e6; font-family: Consolas; font-size: 10pt;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; font-size: 10pt;"&gt; &lt;SPAN style="color: black;"&gt;id ordervar&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000e6; font-family: Consolas; font-size: 10pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; font-size: 10pt;"&gt; &lt;SPAN style="color: black;"&gt;first.id=&lt;/SPAN&gt;&lt;SPAN style="color: purple;"&gt;1&lt;/SPAN&gt; &lt;SPAN style="color: #0000e6;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="color: #0000e6;"&gt;output&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #0000e6; font-size: 10pt; font-family: Consolas;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #0000e6; font-size: 10pt; font-family: Consolas;"&gt;proc&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; font-size: 10pt;"&gt; &lt;STRONG style="color: #0000e6;"&gt;sql&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000e6; font-family: Consolas; font-size: 10pt;"&gt;create&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; font-size: 10pt;"&gt; &lt;SPAN style="color: #0000e6;"&gt;table&lt;/SPAN&gt;&lt;SPAN style="color: black;"&gt; answer &lt;/SPAN&gt;&lt;SPAN style="color: #0000e6;"&gt;as&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000e6; font-family: Consolas; font-size: 10pt;"&gt;select&lt;/SPAN&gt; &lt;SPAN style="color: teal; font-family: Consolas; font-size: 10pt;"&gt;t1.&lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;*&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt;,t1.dxday-jv.dxday &lt;/SPAN&gt;&lt;SPAN style="color: #0000e6; font-family: Consolas; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt; diff&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000e6; font-family: Consolas; font-size: 10pt;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt; test t1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000e6; font-family: Consolas; font-size: 10pt;"&gt;join&lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt; joinvalues jv &lt;/SPAN&gt;&lt;SPAN style="color: #0000e6; font-family: Consolas; font-size: 10pt;"&gt;on&lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: Consolas; font-size: 10pt;"&gt; jv.id=t1.id&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #0000e6; font-size: 10pt; font-family: Consolas;"&gt;quit&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #0000e6; font-size: 10pt; font-family: Consolas;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 15:50:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-differences-from-a-baseline-value/m-p/131949#M26888</guid>
      <dc:creator>Anotherdream</dc:creator>
      <dc:date>2013-07-11T15:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate differences from a baseline value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-differences-from-a-baseline-value/m-p/131950#M26889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Chucs,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;May be some one come up with better answer. here is the sample code where you can get the desired o/p&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;sql&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;create&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;table&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; want &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;select&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: teal; font-size: 10pt;"&gt;a.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;*,b.baseday,(dxday-baseday) &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; diff&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; have &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; a left join(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; id,dxday &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; baseday&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; have(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;=(caetype eq &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: purple; font-size: 10pt;"&gt;'INFL'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; id having dxday=min(dxday)) &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; b&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;on&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; a.id=b.id&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;order&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; a.id,a.dxday;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;quit&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Sam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 18:11:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-differences-from-a-baseline-value/m-p/131950#M26889</guid>
      <dc:creator>sam369</dc:creator>
      <dc:date>2013-07-11T18:11:01Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate differences from a baseline value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-differences-from-a-baseline-value/m-p/131951#M26890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Chucs,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SQL is more of my weak spot, so I would go about it like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do until (last.id);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by id;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if baseline =. and caetype='INFL' then baseline = dxday;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do until (last.id);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by id;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; diff = dxday - baseline;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The logic assumes that your data are already in order BY ID DXDAY.&amp;nbsp; Optionally, you might want to drop BASELINE;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 20:03:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-differences-from-a-baseline-value/m-p/131951#M26890</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-07-11T20:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate differences from a baseline value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-differences-from-a-baseline-value/m-p/131952#M26891</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks to everyone for their response! I'll give them a try.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jul 2013 15:30:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-differences-from-a-baseline-value/m-p/131952#M26891</guid>
      <dc:creator>chucs</dc:creator>
      <dc:date>2013-07-12T15:30:41Z</dc:date>
    </item>
  </channel>
</rss>

