<?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: Difference from Baseline Calculation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Difference-from-Baseline-Calculation/m-p/440037#M109858</link>
    <description>&lt;P&gt;This is an alternative to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;'s suggestion.&amp;nbsp; It takes advantage of the DIF function (where dif(x) is defined as x-lag(x)), and interspersing&amp;nbsp;a baseline observation between each of the other visits:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 informat visit $25.;
 input visit &amp;amp; n Mean SD Med Q1 Q3 Min Max;
 cards;
Baseline Visit           48 33.8 9.6 32.6 26.2 38.1 18.6 59.7
6 Week Follow-up         35 37.8 7.1 38.1 31.2 42.2 22.8 52.5
3 Month Follow-up        25 42.3 8 42.4 37.3 47.8 18.4 56.4
6 Month Follow-up        2 54.5 1.5 54.5 53.5 55.6 53.5 55.6
run;


data want (drop=i);
  set have (where=(visit=:'B'))
      have (where=(visit=:'6 Week') in=in6w)
      have (where=(visit=:'B'))
      have (where=(visit=:'3 M') in=in3m)
      have (where=(visit=:'B'))
      have (where=(visit=:'6 M') in=in6m);
  array x {*} mean--max;
  do i=1 to dim(x);
    x{i}=dif(x{i}); 
  end;
  if in6w or in3m or in6m;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SET statement interleaves 6 subsets of HAVE, where one subset (visit=:'B') is read 3 times, once preceding the visit=:'6 W', once before visit=:'3 M' and once preceding '6 M'.&amp;nbsp; This means the DIF function, which calculates x-lag(X), will be generating&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X at 6 weeks minus X at baseline&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X at 3 months minus X at baseline&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X at 6 months minus X at baseline&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The&amp;nbsp;&amp;nbsp; "where" parameters use the operator&amp;nbsp; "=:", which says to take the shorter string and compare it only to the start of the longer string.&lt;/P&gt;</description>
    <pubDate>Sun, 25 Feb 2018 17:09:56 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2018-02-25T17:09:56Z</dc:date>
    <item>
      <title>Difference from Baseline Calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-from-Baseline-Calculation/m-p/439921#M109812</link>
      <description>&lt;P&gt;Hey all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I have some output from PROC MEANS where I have some basic values spread across four visits.&amp;nbsp; The first visit is considered the baseline visit.&lt;BR /&gt;&lt;BR /&gt;I am trying to crate a dataset that contains the difference from baseline for each variable at each visit:&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="example.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18794i990F0DD5547FB7F9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="example.png" alt="example.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Anyone have any thoughts on how I can do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Feb 2018 05:39:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-from-Baseline-Calculation/m-p/439921#M109812</guid>
      <dc:creator>kryden</dc:creator>
      <dc:date>2018-02-24T05:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: Difference from Baseline Calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-from-Baseline-Calculation/m-p/439950#M109823</link>
      <description>&lt;P&gt;Here is one way:&lt;/P&gt;
&lt;PRE&gt;data have;&lt;BR /&gt; informat visit $25.;&lt;BR /&gt; input visit &amp;amp; n Mean SD Med Q1 Q3 Min Max;&lt;BR /&gt; cards;&lt;BR /&gt;Baseline Visit   48 33.8 9.6 32.6 26.2 38.1 18.6 59.7&lt;BR /&gt;6 Week Follow-up   35 37.8 7.1 38.1 31.2 42.2 22.8 52.5&lt;BR /&gt;3 Month Follow-up    25 42.3 8 42.4 37.3 47.8 18.4 56.4&lt;BR /&gt;6 Month Follow-up    2 54.5 1.5 54.5 53.5 55.6 53.5 55.6&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;data want (drop=_:);&lt;BR /&gt; set have;&lt;BR /&gt; retain _Mean _SD _Med _Q1 _Q3 _Min _Max;&lt;BR /&gt; if _n_ eq 1 then do;&lt;BR /&gt; _Mean=Mean;&lt;BR /&gt; _SD=SD;&lt;BR /&gt; _Med=Med;&lt;BR /&gt; _Q1=Q1;&lt;BR /&gt; _Q3=Q3;&lt;BR /&gt; _Min=Min;&lt;BR /&gt; _Max=Max;&lt;BR /&gt; end;&lt;BR /&gt; else do;&lt;BR /&gt; Mean+-_Mean;&lt;BR /&gt; SD+-_SD;&lt;BR /&gt; Med+-_Med;&lt;BR /&gt; Q1+-_Q1;&lt;BR /&gt; Q3+-_Q3;&lt;BR /&gt; Min+-_Min;&lt;BR /&gt; Max+-_Max;&lt;BR /&gt; output;&lt;BR /&gt; end;&lt;BR /&gt;run;&lt;BR /&gt;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: Corrected to drop retained variables&lt;/P&gt;</description>
      <pubDate>Sat, 24 Feb 2018 23:40:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-from-Baseline-Calculation/m-p/439950#M109823</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-02-24T23:40:48Z</dc:date>
    </item>
    <item>
      <title>Re: Difference from Baseline Calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-from-Baseline-Calculation/m-p/440037#M109858</link>
      <description>&lt;P&gt;This is an alternative to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;'s suggestion.&amp;nbsp; It takes advantage of the DIF function (where dif(x) is defined as x-lag(x)), and interspersing&amp;nbsp;a baseline observation between each of the other visits:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 informat visit $25.;
 input visit &amp;amp; n Mean SD Med Q1 Q3 Min Max;
 cards;
Baseline Visit           48 33.8 9.6 32.6 26.2 38.1 18.6 59.7
6 Week Follow-up         35 37.8 7.1 38.1 31.2 42.2 22.8 52.5
3 Month Follow-up        25 42.3 8 42.4 37.3 47.8 18.4 56.4
6 Month Follow-up        2 54.5 1.5 54.5 53.5 55.6 53.5 55.6
run;


data want (drop=i);
  set have (where=(visit=:'B'))
      have (where=(visit=:'6 Week') in=in6w)
      have (where=(visit=:'B'))
      have (where=(visit=:'3 M') in=in3m)
      have (where=(visit=:'B'))
      have (where=(visit=:'6 M') in=in6m);
  array x {*} mean--max;
  do i=1 to dim(x);
    x{i}=dif(x{i}); 
  end;
  if in6w or in3m or in6m;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SET statement interleaves 6 subsets of HAVE, where one subset (visit=:'B') is read 3 times, once preceding the visit=:'6 W', once before visit=:'3 M' and once preceding '6 M'.&amp;nbsp; This means the DIF function, which calculates x-lag(X), will be generating&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X at 6 weeks minus X at baseline&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X at 3 months minus X at baseline&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X at 6 months minus X at baseline&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The&amp;nbsp;&amp;nbsp; "where" parameters use the operator&amp;nbsp; "=:", which says to take the shorter string and compare it only to the start of the longer string.&lt;/P&gt;</description>
      <pubDate>Sun, 25 Feb 2018 17:09:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-from-Baseline-Calculation/m-p/440037#M109858</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-02-25T17:09:56Z</dc:date>
    </item>
  </channel>
</rss>

