<?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 Substracting variables at different timepoints in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Substracting-variables-at-different-timepoints/m-p/797281#M255930</link>
    <description>&lt;P&gt;I have 50 patients measured at 3&amp;nbsp; timepoints (control, baseline, post). The number of variables is greater than 200. Data has vertitical structure:&lt;/P&gt;&lt;P&gt;control&lt;/P&gt;&lt;P&gt;baseline&lt;/P&gt;&lt;P&gt;post&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I enclose small part of for illustration (with only 4 variables):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SUBJECT,TIME,VAR1,VAR2,VAR3,VAR4&lt;BR /&gt;1,Control ,17.20,18.50,10.10,-6.20&lt;BR /&gt;2,Control ,16.30,2.30,8.20,5.00&lt;BR /&gt;3,Control ,4.50,4.50,6.30,2.00&lt;BR /&gt;4,Control ,8.30,6.30,12.20,7.00&lt;BR /&gt;5,Control ,8.80,17.30,7.20,8.50&lt;BR /&gt;6,Control ,12.20,2.30,16.00,11.30&lt;BR /&gt;7,Control ,6.85,5.11,13.24,14.90&lt;BR /&gt;8,Control ,5.60,4.14,14.17,17.84&lt;BR /&gt;9,Control ,4.35,3.16,15.09,20.79&lt;BR /&gt;10,Control ,3.10,2.18,16.02,23.73&lt;BR /&gt;11,Control ,1.85,1.20,16.94,26.67&lt;BR /&gt;12,Control ,0.60,0.23,17.87,29.61&lt;BR /&gt;13,Control ,-0.64,-0.75,18.79,32.56&lt;BR /&gt;14,Control ,-1.89,-1.73,19.72,35.50&lt;BR /&gt;15,Control ,-3.14,-2.70,20.65,38.44&lt;BR /&gt;16,Control ,-4.39,-3.68,21.57,41.39&lt;BR /&gt;17,Control ,-5.64,-4.66,22.50,44.33&lt;BR /&gt;18,Control ,-6.89,-5.64,23.42,47.27&lt;BR /&gt;19,Control ,-8.14,-6.61,24.35,50.21&lt;BR /&gt;20,Control ,-9.38,-7.59,25.27,53.16&lt;BR /&gt;21,Control ,-10.63,-8.57,26.20,56.10&lt;BR /&gt;22,Control ,-11.88,-9.54,27.13,59.04&lt;BR /&gt;23,Control ,-13.13,-10.52,28.05,61.99&lt;BR /&gt;24,Control ,-14.38,-11.50,28.98,64.93&lt;BR /&gt;25,Control ,-15.63,-12.48,29.90,67.87&lt;BR /&gt;26,Control ,-16.88,-13.45,30.83,70.81&lt;BR /&gt;27,Control ,-18.12,-14.43,31.75,73.76&lt;BR /&gt;28,Control ,-19.37,-15.41,32.68,76.70&lt;BR /&gt;29,Control ,-20.62,-16.38,33.61,79.64&lt;BR /&gt;30,Control ,-21.87,-17.36,34.53,82.59&lt;BR /&gt;31,Control ,-23.12,-18.34,35.46,85.53&lt;BR /&gt;32,Control ,-24.37,-19.32,36.38,88.47&lt;BR /&gt;33,Control ,-25.62,-20.29,37.31,91.41&lt;BR /&gt;34,Control ,-26.86,-21.27,38.23,94.36&lt;BR /&gt;35,Control ,-28.11,-22.25,39.16,97.30&lt;BR /&gt;36,Control ,-29.36,-23.22,40.09,100.24&lt;BR /&gt;37,Control ,-30.61,-24.20,41.01,103.19&lt;BR /&gt;38,Control ,-31.86,-25.18,41.94,106.13&lt;BR /&gt;39,Control ,-33.11,-26.16,42.86,109.07&lt;BR /&gt;40,Control ,-34.36,-27.13,43.79,112.01&lt;BR /&gt;41,Control ,-35.60,-28.11,44.71,114.96&lt;BR /&gt;42,Control ,-36.85,-29.09,45.64,117.90&lt;BR /&gt;43,Control ,-38.10,-30.06,46.57,120.84&lt;BR /&gt;44,Control ,-39.35,-31.04,47.49,123.79&lt;BR /&gt;45,Control ,-40.60,-32.02,48.42,126.73&lt;BR /&gt;46,Control ,-41.85,-33.00,49.34,129.67&lt;BR /&gt;47,Control ,-43.10,-33.97,50.27,132.61&lt;BR /&gt;48,Control ,-44.34,-34.95,51.19,135.56&lt;BR /&gt;49,Control ,-45.59,-35.93,52.12,138.50&lt;BR /&gt;50,Control ,-46.84,-36.90,53.05,141.44&lt;BR /&gt;1,Baseline ,-48.09,-37.88,53.97,144.39&lt;BR /&gt;2,Baseline ,-49.34,-38.86,54.90,147.33&lt;BR /&gt;3,Baseline ,-50.59,-39.84,55.82,150.27&lt;BR /&gt;4,Baseline ,-51.84,-40.81,56.75,153.21&lt;BR /&gt;5,Baseline ,-53.08,-41.79,57.67,156.16&lt;BR /&gt;6,Baseline ,-54.33,-42.77,58.60,159.10&lt;BR /&gt;7,Baseline ,-55.58,-43.74,59.53,162.04&lt;BR /&gt;8,Baseline ,-56.83,-44.72,60.45,164.99&lt;BR /&gt;9,Baseline ,-58.08,-45.70,61.38,167.93&lt;BR /&gt;10,Baseline ,-59.33,-46.68,62.30,170.87&lt;BR /&gt;11,Baseline ,-60.58,-47.65,63.23,173.81&lt;BR /&gt;12,Baseline ,-61.82,-48.63,64.15,176.76&lt;BR /&gt;13,Baseline ,-63.07,-49.61,65.08,179.70&lt;BR /&gt;14,Baseline ,-64.32,-50.58,66.01,182.64&lt;BR /&gt;15,Baseline ,-65.57,-51.56,66.93,185.59&lt;BR /&gt;16,Baseline ,-66.82,-52.54,67.86,188.53&lt;BR /&gt;17,Baseline ,-68.07,-53.52,68.78,191.47&lt;BR /&gt;18,Baseline ,-69.32,-54.49,69.71,194.41&lt;BR /&gt;19,Baseline ,-70.56,-55.47,70.63,197.36&lt;BR /&gt;20,Baseline ,-71.81,-56.45,71.56,200.30&lt;BR /&gt;21,Baseline ,-73.06,-57.42,72.49,203.24&lt;BR /&gt;22,Baseline ,-74.31,-58.40,73.41,206.19&lt;BR /&gt;23,Baseline ,-75.56,-59.38,74.34,209.13&lt;BR /&gt;24,Baseline ,-76.81,-60.36,75.26,212.07&lt;BR /&gt;25,Baseline ,-78.06,-61.33,76.19,215.01&lt;BR /&gt;26,Baseline ,-79.30,-62.31,77.11,217.96&lt;BR /&gt;27,Baseline ,-80.55,-63.29,78.04,220.90&lt;BR /&gt;28,Baseline ,-81.80,-64.26,78.97,223.84&lt;BR /&gt;29,Baseline ,-83.05,-65.24,79.89,226.79&lt;BR /&gt;30,Baseline ,-84.30,-66.22,80.82,229.73&lt;BR /&gt;31,Baseline ,-85.55,-67.20,81.74,232.67&lt;BR /&gt;32,Baseline ,-86.80,-68.17,82.67,235.61&lt;BR /&gt;33,Baseline ,-88.04,-69.15,83.59,238.56&lt;BR /&gt;34,Baseline ,-89.29,-70.13,84.52,241.50&lt;BR /&gt;35,Baseline ,-90.54,-71.10,85.45,244.44&lt;BR /&gt;36,Baseline ,-91.79,-72.08,86.37,247.39&lt;BR /&gt;37,Baseline ,-93.04,-73.06,87.30,250.33&lt;BR /&gt;38,Baseline ,-94.29,-74.04,88.22,253.27&lt;BR /&gt;39,Baseline ,-95.54,-75.01,89.15,256.21&lt;BR /&gt;40,Baseline ,-96.78,-75.99,90.07,259.16&lt;BR /&gt;41,Baseline ,-98.03,-76.97,91.00,262.10&lt;BR /&gt;42,Baseline ,-99.28,-77.94,91.93,265.04&lt;BR /&gt;43,Baseline ,-100.53,-78.92,92.85,267.99&lt;BR /&gt;44,Baseline ,-101.78,-79.90,93.78,270.93&lt;BR /&gt;45,Baseline ,-103.03,-80.88,94.70,273.87&lt;BR /&gt;46,Baseline ,-104.28,-81.85,95.63,276.81&lt;BR /&gt;47,Baseline ,-105.52,-82.83,96.55,279.76&lt;BR /&gt;48,Baseline ,-106.77,-83.81,97.48,282.70&lt;BR /&gt;49,Baseline ,-108.02,-84.78,98.41,285.64&lt;BR /&gt;50,Baseline ,-109.27,-85.76,99.33,288.59&lt;BR /&gt;1,post,-110.52,-86.74,100.26,291.53&lt;BR /&gt;2,post,-111.77,-87.72,101.18,294.47&lt;BR /&gt;3,post,-113.02,-88.69,102.11,297.41&lt;BR /&gt;4,post,-114.26,-89.67,103.03,300.36&lt;BR /&gt;5,post,-115.51,-90.65,103.96,303.30&lt;BR /&gt;6,post,-116.76,-91.62,104.89,306.24&lt;BR /&gt;7,post,-118.01,-92.60,105.81,309.19&lt;BR /&gt;8,post,-119.26,-93.58,106.74,312.13&lt;BR /&gt;9,post,-120.51,-94.56,107.66,315.07&lt;BR /&gt;10,post,-121.76,-95.53,108.59,318.01&lt;BR /&gt;11,post,-123.00,-96.51,109.51,320.96&lt;BR /&gt;12,post,-124.25,-97.49,110.44,323.90&lt;BR /&gt;13,post,-125.50,-98.46,111.37,326.84&lt;BR /&gt;14,post,-126.75,-99.44,112.29,329.79&lt;BR /&gt;15,post,-128.00,-100.42,113.22,332.73&lt;BR /&gt;16,post,-129.25,-101.40,114.14,335.67&lt;BR /&gt;17,post,-130.50,-102.37,115.07,338.61&lt;BR /&gt;18,post,-131.74,-103.35,115.99,341.56&lt;BR /&gt;19,post,-132.99,-104.33,116.92,344.50&lt;BR /&gt;20,post,-134.24,-105.30,117.85,347.44&lt;BR /&gt;21,post,-135.49,-106.28,118.77,350.39&lt;BR /&gt;22,post,-136.74,-107.26,119.70,353.33&lt;BR /&gt;23,post,-137.99,-108.24,120.62,356.27&lt;BR /&gt;24,post,-139.24,-109.21,121.55,359.21&lt;BR /&gt;25,post,-140.48,-110.19,122.47,362.16&lt;BR /&gt;26,post,-141.73,-111.17,123.40,365.10&lt;BR /&gt;27,post,-142.98,-112.14,124.33,368.04&lt;BR /&gt;28,post,-144.23,-113.12,125.25,370.99&lt;BR /&gt;29,post,-145.48,-114.10,126.18,373.93&lt;BR /&gt;30,post,-146.73,-115.08,127.10,376.87&lt;BR /&gt;31,post,-147.98,-116.05,128.03,379.81&lt;BR /&gt;32,post,-149.22,-117.03,128.95,382.76&lt;BR /&gt;33,post,-150.47,-118.01,129.88,385.70&lt;BR /&gt;34,post,-151.72,-118.98,130.81,388.64&lt;BR /&gt;35,post,-152.97,-119.96,131.73,391.59&lt;BR /&gt;36,post,-154.22,-120.94,132.66,394.53&lt;BR /&gt;37,post,-155.47,-121.92,133.58,397.47&lt;BR /&gt;38,post,-156.72,-122.89,134.51,400.41&lt;BR /&gt;39,post,-157.96,-123.87,135.43,403.36&lt;BR /&gt;40,post,-159.21,-124.85,136.36,406.30&lt;BR /&gt;41,post,-160.46,-125.82,137.29,409.24&lt;BR /&gt;42,post,-161.71,-126.80,138.21,412.19&lt;BR /&gt;43,post,-162.96,-127.78,139.14,415.13&lt;BR /&gt;44,post,-164.21,-128.76,140.06,418.07&lt;BR /&gt;45,post,-165.46,-129.73,140.99,421.01&lt;BR /&gt;46,post,-166.70,-130.71,141.91,423.96&lt;BR /&gt;47,post,-167.95,-131.69,142.84,426.90&lt;BR /&gt;48,post,-169.20,-132.66,143.77,429.84&lt;BR /&gt;49,post,-170.45,-133.64,144.69,432.79&lt;BR /&gt;50,post,-171.70,-134.62,145.62,435.73&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm intrested in measuring the effect between the timepoints, which is to substract control from baseline, control from post, baseline from post ( apply this to 4 variables). The final data should consist only of subjects and variables (after being trasformed to effects), either in horizontal or vertical structure.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate your help&lt;/P&gt;</description>
    <pubDate>Fri, 18 Feb 2022 17:05:42 GMT</pubDate>
    <dc:creator>Job04</dc:creator>
    <dc:date>2022-02-18T17:05:42Z</dc:date>
    <item>
      <title>Substracting variables at different timepoints</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substracting-variables-at-different-timepoints/m-p/797281#M255930</link>
      <description>&lt;P&gt;I have 50 patients measured at 3&amp;nbsp; timepoints (control, baseline, post). The number of variables is greater than 200. Data has vertitical structure:&lt;/P&gt;&lt;P&gt;control&lt;/P&gt;&lt;P&gt;baseline&lt;/P&gt;&lt;P&gt;post&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I enclose small part of for illustration (with only 4 variables):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SUBJECT,TIME,VAR1,VAR2,VAR3,VAR4&lt;BR /&gt;1,Control ,17.20,18.50,10.10,-6.20&lt;BR /&gt;2,Control ,16.30,2.30,8.20,5.00&lt;BR /&gt;3,Control ,4.50,4.50,6.30,2.00&lt;BR /&gt;4,Control ,8.30,6.30,12.20,7.00&lt;BR /&gt;5,Control ,8.80,17.30,7.20,8.50&lt;BR /&gt;6,Control ,12.20,2.30,16.00,11.30&lt;BR /&gt;7,Control ,6.85,5.11,13.24,14.90&lt;BR /&gt;8,Control ,5.60,4.14,14.17,17.84&lt;BR /&gt;9,Control ,4.35,3.16,15.09,20.79&lt;BR /&gt;10,Control ,3.10,2.18,16.02,23.73&lt;BR /&gt;11,Control ,1.85,1.20,16.94,26.67&lt;BR /&gt;12,Control ,0.60,0.23,17.87,29.61&lt;BR /&gt;13,Control ,-0.64,-0.75,18.79,32.56&lt;BR /&gt;14,Control ,-1.89,-1.73,19.72,35.50&lt;BR /&gt;15,Control ,-3.14,-2.70,20.65,38.44&lt;BR /&gt;16,Control ,-4.39,-3.68,21.57,41.39&lt;BR /&gt;17,Control ,-5.64,-4.66,22.50,44.33&lt;BR /&gt;18,Control ,-6.89,-5.64,23.42,47.27&lt;BR /&gt;19,Control ,-8.14,-6.61,24.35,50.21&lt;BR /&gt;20,Control ,-9.38,-7.59,25.27,53.16&lt;BR /&gt;21,Control ,-10.63,-8.57,26.20,56.10&lt;BR /&gt;22,Control ,-11.88,-9.54,27.13,59.04&lt;BR /&gt;23,Control ,-13.13,-10.52,28.05,61.99&lt;BR /&gt;24,Control ,-14.38,-11.50,28.98,64.93&lt;BR /&gt;25,Control ,-15.63,-12.48,29.90,67.87&lt;BR /&gt;26,Control ,-16.88,-13.45,30.83,70.81&lt;BR /&gt;27,Control ,-18.12,-14.43,31.75,73.76&lt;BR /&gt;28,Control ,-19.37,-15.41,32.68,76.70&lt;BR /&gt;29,Control ,-20.62,-16.38,33.61,79.64&lt;BR /&gt;30,Control ,-21.87,-17.36,34.53,82.59&lt;BR /&gt;31,Control ,-23.12,-18.34,35.46,85.53&lt;BR /&gt;32,Control ,-24.37,-19.32,36.38,88.47&lt;BR /&gt;33,Control ,-25.62,-20.29,37.31,91.41&lt;BR /&gt;34,Control ,-26.86,-21.27,38.23,94.36&lt;BR /&gt;35,Control ,-28.11,-22.25,39.16,97.30&lt;BR /&gt;36,Control ,-29.36,-23.22,40.09,100.24&lt;BR /&gt;37,Control ,-30.61,-24.20,41.01,103.19&lt;BR /&gt;38,Control ,-31.86,-25.18,41.94,106.13&lt;BR /&gt;39,Control ,-33.11,-26.16,42.86,109.07&lt;BR /&gt;40,Control ,-34.36,-27.13,43.79,112.01&lt;BR /&gt;41,Control ,-35.60,-28.11,44.71,114.96&lt;BR /&gt;42,Control ,-36.85,-29.09,45.64,117.90&lt;BR /&gt;43,Control ,-38.10,-30.06,46.57,120.84&lt;BR /&gt;44,Control ,-39.35,-31.04,47.49,123.79&lt;BR /&gt;45,Control ,-40.60,-32.02,48.42,126.73&lt;BR /&gt;46,Control ,-41.85,-33.00,49.34,129.67&lt;BR /&gt;47,Control ,-43.10,-33.97,50.27,132.61&lt;BR /&gt;48,Control ,-44.34,-34.95,51.19,135.56&lt;BR /&gt;49,Control ,-45.59,-35.93,52.12,138.50&lt;BR /&gt;50,Control ,-46.84,-36.90,53.05,141.44&lt;BR /&gt;1,Baseline ,-48.09,-37.88,53.97,144.39&lt;BR /&gt;2,Baseline ,-49.34,-38.86,54.90,147.33&lt;BR /&gt;3,Baseline ,-50.59,-39.84,55.82,150.27&lt;BR /&gt;4,Baseline ,-51.84,-40.81,56.75,153.21&lt;BR /&gt;5,Baseline ,-53.08,-41.79,57.67,156.16&lt;BR /&gt;6,Baseline ,-54.33,-42.77,58.60,159.10&lt;BR /&gt;7,Baseline ,-55.58,-43.74,59.53,162.04&lt;BR /&gt;8,Baseline ,-56.83,-44.72,60.45,164.99&lt;BR /&gt;9,Baseline ,-58.08,-45.70,61.38,167.93&lt;BR /&gt;10,Baseline ,-59.33,-46.68,62.30,170.87&lt;BR /&gt;11,Baseline ,-60.58,-47.65,63.23,173.81&lt;BR /&gt;12,Baseline ,-61.82,-48.63,64.15,176.76&lt;BR /&gt;13,Baseline ,-63.07,-49.61,65.08,179.70&lt;BR /&gt;14,Baseline ,-64.32,-50.58,66.01,182.64&lt;BR /&gt;15,Baseline ,-65.57,-51.56,66.93,185.59&lt;BR /&gt;16,Baseline ,-66.82,-52.54,67.86,188.53&lt;BR /&gt;17,Baseline ,-68.07,-53.52,68.78,191.47&lt;BR /&gt;18,Baseline ,-69.32,-54.49,69.71,194.41&lt;BR /&gt;19,Baseline ,-70.56,-55.47,70.63,197.36&lt;BR /&gt;20,Baseline ,-71.81,-56.45,71.56,200.30&lt;BR /&gt;21,Baseline ,-73.06,-57.42,72.49,203.24&lt;BR /&gt;22,Baseline ,-74.31,-58.40,73.41,206.19&lt;BR /&gt;23,Baseline ,-75.56,-59.38,74.34,209.13&lt;BR /&gt;24,Baseline ,-76.81,-60.36,75.26,212.07&lt;BR /&gt;25,Baseline ,-78.06,-61.33,76.19,215.01&lt;BR /&gt;26,Baseline ,-79.30,-62.31,77.11,217.96&lt;BR /&gt;27,Baseline ,-80.55,-63.29,78.04,220.90&lt;BR /&gt;28,Baseline ,-81.80,-64.26,78.97,223.84&lt;BR /&gt;29,Baseline ,-83.05,-65.24,79.89,226.79&lt;BR /&gt;30,Baseline ,-84.30,-66.22,80.82,229.73&lt;BR /&gt;31,Baseline ,-85.55,-67.20,81.74,232.67&lt;BR /&gt;32,Baseline ,-86.80,-68.17,82.67,235.61&lt;BR /&gt;33,Baseline ,-88.04,-69.15,83.59,238.56&lt;BR /&gt;34,Baseline ,-89.29,-70.13,84.52,241.50&lt;BR /&gt;35,Baseline ,-90.54,-71.10,85.45,244.44&lt;BR /&gt;36,Baseline ,-91.79,-72.08,86.37,247.39&lt;BR /&gt;37,Baseline ,-93.04,-73.06,87.30,250.33&lt;BR /&gt;38,Baseline ,-94.29,-74.04,88.22,253.27&lt;BR /&gt;39,Baseline ,-95.54,-75.01,89.15,256.21&lt;BR /&gt;40,Baseline ,-96.78,-75.99,90.07,259.16&lt;BR /&gt;41,Baseline ,-98.03,-76.97,91.00,262.10&lt;BR /&gt;42,Baseline ,-99.28,-77.94,91.93,265.04&lt;BR /&gt;43,Baseline ,-100.53,-78.92,92.85,267.99&lt;BR /&gt;44,Baseline ,-101.78,-79.90,93.78,270.93&lt;BR /&gt;45,Baseline ,-103.03,-80.88,94.70,273.87&lt;BR /&gt;46,Baseline ,-104.28,-81.85,95.63,276.81&lt;BR /&gt;47,Baseline ,-105.52,-82.83,96.55,279.76&lt;BR /&gt;48,Baseline ,-106.77,-83.81,97.48,282.70&lt;BR /&gt;49,Baseline ,-108.02,-84.78,98.41,285.64&lt;BR /&gt;50,Baseline ,-109.27,-85.76,99.33,288.59&lt;BR /&gt;1,post,-110.52,-86.74,100.26,291.53&lt;BR /&gt;2,post,-111.77,-87.72,101.18,294.47&lt;BR /&gt;3,post,-113.02,-88.69,102.11,297.41&lt;BR /&gt;4,post,-114.26,-89.67,103.03,300.36&lt;BR /&gt;5,post,-115.51,-90.65,103.96,303.30&lt;BR /&gt;6,post,-116.76,-91.62,104.89,306.24&lt;BR /&gt;7,post,-118.01,-92.60,105.81,309.19&lt;BR /&gt;8,post,-119.26,-93.58,106.74,312.13&lt;BR /&gt;9,post,-120.51,-94.56,107.66,315.07&lt;BR /&gt;10,post,-121.76,-95.53,108.59,318.01&lt;BR /&gt;11,post,-123.00,-96.51,109.51,320.96&lt;BR /&gt;12,post,-124.25,-97.49,110.44,323.90&lt;BR /&gt;13,post,-125.50,-98.46,111.37,326.84&lt;BR /&gt;14,post,-126.75,-99.44,112.29,329.79&lt;BR /&gt;15,post,-128.00,-100.42,113.22,332.73&lt;BR /&gt;16,post,-129.25,-101.40,114.14,335.67&lt;BR /&gt;17,post,-130.50,-102.37,115.07,338.61&lt;BR /&gt;18,post,-131.74,-103.35,115.99,341.56&lt;BR /&gt;19,post,-132.99,-104.33,116.92,344.50&lt;BR /&gt;20,post,-134.24,-105.30,117.85,347.44&lt;BR /&gt;21,post,-135.49,-106.28,118.77,350.39&lt;BR /&gt;22,post,-136.74,-107.26,119.70,353.33&lt;BR /&gt;23,post,-137.99,-108.24,120.62,356.27&lt;BR /&gt;24,post,-139.24,-109.21,121.55,359.21&lt;BR /&gt;25,post,-140.48,-110.19,122.47,362.16&lt;BR /&gt;26,post,-141.73,-111.17,123.40,365.10&lt;BR /&gt;27,post,-142.98,-112.14,124.33,368.04&lt;BR /&gt;28,post,-144.23,-113.12,125.25,370.99&lt;BR /&gt;29,post,-145.48,-114.10,126.18,373.93&lt;BR /&gt;30,post,-146.73,-115.08,127.10,376.87&lt;BR /&gt;31,post,-147.98,-116.05,128.03,379.81&lt;BR /&gt;32,post,-149.22,-117.03,128.95,382.76&lt;BR /&gt;33,post,-150.47,-118.01,129.88,385.70&lt;BR /&gt;34,post,-151.72,-118.98,130.81,388.64&lt;BR /&gt;35,post,-152.97,-119.96,131.73,391.59&lt;BR /&gt;36,post,-154.22,-120.94,132.66,394.53&lt;BR /&gt;37,post,-155.47,-121.92,133.58,397.47&lt;BR /&gt;38,post,-156.72,-122.89,134.51,400.41&lt;BR /&gt;39,post,-157.96,-123.87,135.43,403.36&lt;BR /&gt;40,post,-159.21,-124.85,136.36,406.30&lt;BR /&gt;41,post,-160.46,-125.82,137.29,409.24&lt;BR /&gt;42,post,-161.71,-126.80,138.21,412.19&lt;BR /&gt;43,post,-162.96,-127.78,139.14,415.13&lt;BR /&gt;44,post,-164.21,-128.76,140.06,418.07&lt;BR /&gt;45,post,-165.46,-129.73,140.99,421.01&lt;BR /&gt;46,post,-166.70,-130.71,141.91,423.96&lt;BR /&gt;47,post,-167.95,-131.69,142.84,426.90&lt;BR /&gt;48,post,-169.20,-132.66,143.77,429.84&lt;BR /&gt;49,post,-170.45,-133.64,144.69,432.79&lt;BR /&gt;50,post,-171.70,-134.62,145.62,435.73&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm intrested in measuring the effect between the timepoints, which is to substract control from baseline, control from post, baseline from post ( apply this to 4 variables). The final data should consist only of subjects and variables (after being trasformed to effects), either in horizontal or vertical structure.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate your help&lt;/P&gt;</description>
      <pubDate>Fri, 18 Feb 2022 17:05:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substracting-variables-at-different-timepoints/m-p/797281#M255930</guid>
      <dc:creator>Job04</dc:creator>
      <dc:date>2022-02-18T17:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: Substracting variables at different timepoints</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substracting-variables-at-different-timepoints/m-p/797287#M255935</link>
      <description>&lt;P&gt;Suggestion: Reduce that example to 4 or 5 of each type, something small enough you can calculate what you want or show directly which calculations are involved and desired result.&lt;/P&gt;
&lt;P&gt;It may help to describe what you will do with the resulting data as the structure may need to be different for different purposes.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Feb 2022 17:31:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substracting-variables-at-different-timepoints/m-p/797287#M255935</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-02-18T17:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: Substracting variables at different timepoints</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substracting-variables-at-different-timepoints/m-p/797303#M260033</link>
      <description>&lt;P&gt;Here is the data for 3 observations:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SUBJECT,SUBJECT,TIME,VAR1,VAR2,VAR3,VAR4&lt;BR /&gt;1,1,Control ,17.20,18.50,10.10,-6.20&lt;BR /&gt;2,2,Control ,16.30,2.30,8.20,5.00&lt;BR /&gt;3,2,Control ,4.50,4.50,6.30,2.00&lt;BR /&gt;1,1,Baseline ,-48.09,-37.88,53.97,144.39&lt;BR /&gt;2,2,Baseline ,-49.34,-38.86,54.90,147.33&lt;BR /&gt;3,3,Baseline ,-50.59,-39.84,55.82,150.27&lt;BR /&gt;1,1,post,-110.52,-86.74,100.26,291.53&lt;BR /&gt;2,2,post,-111.77,-87.72,101.18,294.47&lt;BR /&gt;3,3,post,-113.02,-88.69,102.11,297.41&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Samples are paired. Classification using my mutivariate method requires to calculate the difference in observations between timepoints. For example for patient 1 I have 3 effects per VAR1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did the substraction for only 3 samples:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;SUBJECT&lt;/TD&gt;&lt;TD&gt;VAR1&lt;/TD&gt;&lt;TD&gt;VAR2&lt;/TD&gt;&lt;TD&gt;VAR3&lt;/TD&gt;&lt;TD&gt;VAR4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1 (control-baseline)&lt;/TD&gt;&lt;TD&gt;65.29&lt;/TD&gt;&lt;TD&gt;56.38&lt;/TD&gt;&lt;TD&gt;-43.87&lt;/TD&gt;&lt;TD&gt;-150.59&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2 (control-baseline)&lt;/TD&gt;&lt;TD&gt;65.64&lt;/TD&gt;&lt;TD&gt;41.16&lt;/TD&gt;&lt;TD&gt;-46.70&lt;/TD&gt;&lt;TD&gt;-142.33&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3 (control-baseline)&lt;/TD&gt;&lt;TD&gt;55.09&lt;/TD&gt;&lt;TD&gt;44.34&lt;/TD&gt;&lt;TD&gt;-49.52&lt;/TD&gt;&lt;TD&gt;-148.27&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1 (control-post)&lt;/TD&gt;&lt;TD&gt;127.72&lt;/TD&gt;&lt;TD&gt;105.24&lt;/TD&gt;&lt;TD&gt;-90.16&lt;/TD&gt;&lt;TD&gt;-297.73&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2 (control-post)&lt;/TD&gt;&lt;TD&gt;128.07&lt;/TD&gt;&lt;TD&gt;90.02&lt;/TD&gt;&lt;TD&gt;-92.98&lt;/TD&gt;&lt;TD&gt;-289.47&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3 (control-post)&lt;/TD&gt;&lt;TD&gt;117.52&lt;/TD&gt;&lt;TD&gt;93.19&lt;/TD&gt;&lt;TD&gt;-95.81&lt;/TD&gt;&lt;TD&gt;-295.41&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1 (baseline-post)&lt;/TD&gt;&lt;TD&gt;62.43&lt;/TD&gt;&lt;TD&gt;48.86&lt;/TD&gt;&lt;TD&gt;-46.29&lt;/TD&gt;&lt;TD&gt;-147.14&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2 (baseline-post)&lt;/TD&gt;&lt;TD&gt;62.43&lt;/TD&gt;&lt;TD&gt;48.86&lt;/TD&gt;&lt;TD&gt;-46.29&lt;/TD&gt;&lt;TD&gt;-147.14&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3 (baseline-post)&lt;/TD&gt;&lt;TD&gt;62.43&lt;/TD&gt;&lt;TD&gt;48.86&lt;/TD&gt;&lt;TD&gt;-46.29&lt;/TD&gt;&lt;TD&gt;-147.14&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 18 Feb 2022 19:04:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substracting-variables-at-different-timepoints/m-p/797303#M260033</guid>
      <dc:creator>Job04</dc:creator>
      <dc:date>2022-02-18T19:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: Substracting variables at different timepoints</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substracting-variables-at-different-timepoints/m-p/797364#M287469</link>
      <description>&lt;P&gt;One way to do this is to&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;interleave the 3 observations for subject 1&amp;nbsp; (post followed by baseline followed by control)&lt;/LI&gt;
&lt;LI&gt;For each var get the dif(var), which is simply var minus lag(var).&amp;nbsp; For instances in which time=baseline and lag(time)=post,&amp;nbsp; or time=control and lag(time)=baseline, you will have the control vs baseline and baseline vs posts contrasts.&lt;/LI&gt;
&lt;LI&gt;Also for each var, get the dif2(var), which is simply var minus lag2(var)&amp;nbsp; (i.e. a 2-record lag).&amp;nbsp; For the instance in which time=Control and lag2(time)=post, you will have the Control vs post contrast.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input SUBJECT TIME :$8. VAR1 VAR2 VAR3 VAR4;
datalines;
1 Control  17.20 18.50 10.10 -6.20
2 Control  16.30 2.30 8.20 5.00
3 Control  4.50 4.50 6.30 2.00
4 Control  8.30 6.30 12.20 7.00
5 Control  8.80 17.30 7.20 8.50
6 Control  12.20 2.30 16.00 11.30
7 Control  6.85 5.11 13.24 14.90
8 Control  5.60 4.14 14.17 17.84
9 Control  4.35 3.16 15.09 20.79
10 Control  3.10 2.18 16.02 23.73
11 Control  1.85 1.20 16.94 26.67
12 Control  0.60 0.23 17.87 29.61
13 Control  -0.64 -0.75 18.79 32.56
14 Control  -1.89 -1.73 19.72 35.50
15 Control  -3.14 -2.70 20.65 38.44
16 Control  -4.39 -3.68 21.57 41.39
17 Control  -5.64 -4.66 22.50 44.33
18 Control  -6.89 -5.64 23.42 47.27
19 Control  -8.14 -6.61 24.35 50.21
20 Control  -9.38 -7.59 25.27 53.16
21 Control  -10.63 -8.57 26.20 56.10
22 Control  -11.88 -9.54 27.13 59.04
23 Control  -13.13 -10.52 28.05 61.99
24 Control  -14.38 -11.50 28.98 64.93
25 Control  -15.63 -12.48 29.90 67.87
26 Control  -16.88 -13.45 30.83 70.81
27 Control  -18.12 -14.43 31.75 73.76
28 Control  -19.37 -15.41 32.68 76.70
29 Control  -20.62 -16.38 33.61 79.64
30 Control  -21.87 -17.36 34.53 82.59
31 Control  -23.12 -18.34 35.46 85.53
32 Control  -24.37 -19.32 36.38 88.47
33 Control  -25.62 -20.29 37.31 91.41
34 Control  -26.86 -21.27 38.23 94.36
35 Control  -28.11 -22.25 39.16 97.30
36 Control  -29.36 -23.22 40.09 100.24
37 Control  -30.61 -24.20 41.01 103.19
38 Control  -31.86 -25.18 41.94 106.13
39 Control  -33.11 -26.16 42.86 109.07
40 Control  -34.36 -27.13 43.79 112.01
41 Control  -35.60 -28.11 44.71 114.96
42 Control  -36.85 -29.09 45.64 117.90
43 Control  -38.10 -30.06 46.57 120.84
44 Control  -39.35 -31.04 47.49 123.79
45 Control  -40.60 -32.02 48.42 126.73
46 Control  -41.85 -33.00 49.34 129.67
47 Control  -43.10 -33.97 50.27 132.61
48 Control  -44.34 -34.95 51.19 135.56
49 Control  -45.59 -35.93 52.12 138.50
50 Control  -46.84 -36.90 53.05 141.44
1 Baseline  -48.09 -37.88 53.97 144.39
2 Baseline  -49.34 -38.86 54.90 147.33
3 Baseline  -50.59 -39.84 55.82 150.27
4 Baseline  -51.84 -40.81 56.75 153.21
5 Baseline  -53.08 -41.79 57.67 156.16
6 Baseline  -54.33 -42.77 58.60 159.10
7 Baseline  -55.58 -43.74 59.53 162.04
8 Baseline  -56.83 -44.72 60.45 164.99
9 Baseline  -58.08 -45.70 61.38 167.93
10 Baseline  -59.33 -46.68 62.30 170.87
11 Baseline  -60.58 -47.65 63.23 173.81
12 Baseline  -61.82 -48.63 64.15 176.76
13 Baseline  -63.07 -49.61 65.08 179.70
14 Baseline  -64.32 -50.58 66.01 182.64
15 Baseline  -65.57 -51.56 66.93 185.59
16 Baseline  -66.82 -52.54 67.86 188.53
17 Baseline  -68.07 -53.52 68.78 191.47
18 Baseline  -69.32 -54.49 69.71 194.41
19 Baseline  -70.56 -55.47 70.63 197.36
20 Baseline  -71.81 -56.45 71.56 200.30
21 Baseline  -73.06 -57.42 72.49 203.24
22 Baseline  -74.31 -58.40 73.41 206.19
23 Baseline  -75.56 -59.38 74.34 209.13
24 Baseline  -76.81 -60.36 75.26 212.07
25 Baseline  -78.06 -61.33 76.19 215.01
26 Baseline  -79.30 -62.31 77.11 217.96
27 Baseline  -80.55 -63.29 78.04 220.90
28 Baseline  -81.80 -64.26 78.97 223.84
29 Baseline  -83.05 -65.24 79.89 226.79
30 Baseline  -84.30 -66.22 80.82 229.73
31 Baseline  -85.55 -67.20 81.74 232.67
32 Baseline  -86.80 -68.17 82.67 235.61
33 Baseline  -88.04 -69.15 83.59 238.56
34 Baseline  -89.29 -70.13 84.52 241.50
35 Baseline  -90.54 -71.10 85.45 244.44
36 Baseline  -91.79 -72.08 86.37 247.39
37 Baseline  -93.04 -73.06 87.30 250.33
38 Baseline  -94.29 -74.04 88.22 253.27
39 Baseline  -95.54 -75.01 89.15 256.21
40 Baseline  -96.78 -75.99 90.07 259.16
41 Baseline  -98.03 -76.97 91.00 262.10
42 Baseline  -99.28 -77.94 91.93 265.04
43 Baseline  -100.53 -78.92 92.85 267.99
44 Baseline  -101.78 -79.90 93.78 270.93
45 Baseline  -103.03 -80.88 94.70 273.87
46 Baseline  -104.28 -81.85 95.63 276.81
47 Baseline  -105.52 -82.83 96.55 279.76
48 Baseline  -106.77 -83.81 97.48 282.70
49 Baseline  -108.02 -84.78 98.41 285.64
50 Baseline  -109.27 -85.76 99.33 288.59
1 post -110.52 -86.74 100.26 291.53
2 post -111.77 -87.72 101.18 294.47
3 post -113.02 -88.69 102.11 297.41
4 post -114.26 -89.67 103.03 300.36
5 post -115.51 -90.65 103.96 303.30
6 post -116.76 -91.62 104.89 306.24
7 post -118.01 -92.60 105.81 309.19
8 post -119.26 -93.58 106.74 312.13
9 post -120.51 -94.56 107.66 315.07
10 post -121.76 -95.53 108.59 318.01
11 post -123.00 -96.51 109.51 320.96
12 post -124.25 -97.49 110.44 323.90
13 post -125.50 -98.46 111.37 326.84
14 post -126.75 -99.44 112.29 329.79
15 post -128.00 -100.42 113.22 332.73
16 post -129.25 -101.40 114.14 335.67
17 post -130.50 -102.37 115.07 338.61
18 post -131.74 -103.35 115.99 341.56
19 post -132.99 -104.33 116.92 344.50
20 post -134.24 -105.30 117.85 347.44
21 post -135.49 -106.28 118.77 350.39
22 post -136.74 -107.26 119.70 353.33
23 post -137.99 -108.24 120.62 356.27
24 post -139.24 -109.21 121.55 359.21
25 post -140.48 -110.19 122.47 362.16
26 post -141.73 -111.17 123.40 365.10
27 post -142.98 -112.14 124.33 368.04
28 post -144.23 -113.12 125.25 370.99
29 post -145.48 -114.10 126.18 373.93
30 post -146.73 -115.08 127.10 376.87
31 post -147.98 -116.05 128.03 379.81
32 post -149.22 -117.03 128.95 382.76
33 post -150.47 -118.01 129.88 385.70
34 post -151.72 -118.98 130.81 388.64
35 post -152.97 -119.96 131.73 391.59
36 post -154.22 -120.94 132.66 394.53
37 post -155.47 -121.92 133.58 397.47
38 post -156.72 -122.89 134.51 400.41
39 post -157.96 -123.87 135.43 403.36
40 post -159.21 -124.85 136.36 406.30
41 post -160.46 -125.82 137.29 409.24
42 post -161.71 -126.80 138.21 412.19
43 post -162.96 -127.78 139.14 415.13
44 post -164.21 -128.76 140.06 418.07
45 post -165.46 -129.73 140.99 421.01
46 post -166.70 -130.71 141.91 423.96
47 post -167.95 -131.69 142.84 426.90
48 post -169.20 -132.66 143.77 429.84
49 post -170.45 -133.64 144.69 432.79
50 post -171.70 -134.62 145.62 435.73
run;

data want (drop=_:  time);
  set have (where=(time='post'))
      have (where=(time='Baseline'))
      have (where=(time='Control')) ;
  by subject;
  array vars    var1-var4;
  array diftwo  _diftwo_1 - _diftwo_4;

  do over vars;
    diftwo=dif2(vars);
    vars=dif(vars);
  end;

  length contrast $19;
  contrast=catx(' ',time,'-',lag(time));
  if contrast in('Control - Baseline','Baseline - post') then output;

  if time='Control' and lag2(time)='post' then do;
    contrast='Control - post';
    do over vars;
      vars=diftwo;
    end;
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Of course, this does not produce observations in the order you specify&amp;nbsp; (it will be grouped by contrast within subject_id), but the values will be what you want, and you could sort the resulting file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Crucially, the code above depends on each subject having exactly three time values.&amp;nbsp; A few missing time values could result in say, contrasting Baseline for one subject against post for another, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, to directly produce values in the order you specify, you can use this code:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want  (drop=time);
  array var  var1-var4;

  do contrast='Control - Baseline','Control - post','Baseline - post';

    do until (dif(e1) or dif(e2) or dif(e3));
      if contrast='Control - Baseline' then do; 
        set have (where=(time='Baseline')) have (where=(time='Control'))  end=e1; by subject; 
      end; else
      if contrast='Control - post'     then do; 
        set have (where=(time='post'))     have (where=(time='Control'))  end=e2; by subject; 
      end; else
      if contrast='Baseline - post'    then do; 
        set have (where=(time='post'))     have (where=(time='Baseline')) end=e3; by subject; 
      end; 

      do over var;
        var=dif(var);
      end;
      if last.subject then output; 
    end;
  end;  
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This program first reads all the Baselines followed by the corresponding Control. (that's the BY statement).&amp;nbsp; So each subject id has two observations, and the dif function for the second obs of the subject (i.e. when last.subject=1) produces the Control vs Baseline contrast.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then the program does the same by reading all the posts followed by corresponding Controls.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And finaly the same for all the posts followed by corresponding Baselines.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now this code is more easily modified to accomodate missing time values.&amp;nbsp; Just change:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if last.subject then output;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if first.subject=0 and last.subject=1 then output;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Some notes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "do until (dif(e1) or dif(e2) or dif(e3);" is what tells the major loop to shift from "Control - Baseline" to "Control - post" to "Baseline - post".&amp;nbsp; &amp;nbsp;The e1, e2, and e3 variables are merely end of data dummies for each of the three SET statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Feb 2022 06:34:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substracting-variables-at-different-timepoints/m-p/797364#M287469</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-02-19T06:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: Substracting variables at different timepoints</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substracting-variables-at-different-timepoints/m-p/797377#M287480</link>
      <description>&lt;P&gt;Thank you this worked perfectly with data of dimension 150x4.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My real data&amp;nbsp; has VAR1 to VAR228 and same number of samples. I made little change in this part of the code but didn't work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want (drop=_: time);&lt;BR /&gt;set have (where=(time='post'))&lt;BR /&gt;have (where=(time='Baseline'))&lt;BR /&gt;have (where=(time='Control')) ;&lt;BR /&gt;by subject;&lt;BR /&gt;array vars var1-var228;&lt;BR /&gt;array diftwo _diftwo_1 - _diftwo_;&lt;/P&gt;&lt;P&gt;do over vars;&lt;BR /&gt;diftwo=dif2(vars);&lt;BR /&gt;vars=dif(vars);&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;length contrast $19;&lt;BR /&gt;contrast=catx(' ',time,'-',lag(time));&lt;BR /&gt;if contrast in('Control - Baseline','Baseline - post') then output;&lt;/P&gt;&lt;P&gt;if time='Control' and lag2(time)='post' then do;&lt;BR /&gt;contrast='Control - post';&lt;BR /&gt;do over vars;&lt;BR /&gt;vars=diftwo;&lt;BR /&gt;end;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get this error message:&lt;/P&gt;&lt;P&gt;&amp;nbsp;WARNING: The variable '_:'n in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.WANT may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and 230 variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want I can accept your answer then I post this question&amp;nbsp; in new post.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Feb 2022 11:43:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substracting-variables-at-different-timepoints/m-p/797377#M287480</guid>
      <dc:creator>Job04</dc:creator>
      <dc:date>2022-02-19T11:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: Substracting variables at different timepoints</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substracting-variables-at-different-timepoints/m-p/797386#M287488</link>
      <description>&lt;P&gt;Your response worked very well.&lt;/P&gt;
&lt;P&gt;I mistakenly accepted my reply. Please tell me how&amp;nbsp; can I fix this mistake so the right answer is credited to you.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Feb 2022 14:47:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substracting-variables-at-different-timepoints/m-p/797386#M287488</guid>
      <dc:creator>Job04</dc:creator>
      <dc:date>2022-02-19T14:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: Substracting variables at different timepoints</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substracting-variables-at-different-timepoints/m-p/797388#M287489</link>
      <description>I am unaware of any way to deselect a  response as the accepted answer. &lt;BR /&gt;&lt;BR /&gt;But,  as the author of the selected answer, you can edit it to point to the answer you want readers to see.</description>
      <pubDate>Sat, 19 Feb 2022 14:57:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substracting-variables-at-different-timepoints/m-p/797388#M287489</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-02-19T14:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: Substracting variables at different timepoints</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substracting-variables-at-different-timepoints/m-p/797389#M287490</link>
      <description>&lt;P&gt;I accepted the answer provided by&amp;nbsp; "&lt;A class="trigger-hovercard" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461" target="_blank"&gt;mkeintz&lt;/A&gt;".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Answer was clear, straighforward and solves the questions from the very begining, and applies to any dimension of data that has identical structure as mine.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It&amp;nbsp; was a simple and irrelevant mistake from my part when applying the codes on the original size and&amp;nbsp; names of variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the accepted answer is as initially provided by&amp;nbsp;"&lt;A class="trigger-hovercard" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461" target="_blank"&gt;mkeintz&lt;/A&gt;":&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;data want (drop=_:  time);
  set have (where=(time='post'))
      have (where=(time='Baseline'))
      have (where=(time='Control')) ;
  by subject;
  array vars    var1-var4;
  array diftwo  _diftwo_1 - _diftwo_4;

  do over vars;
    diftwo=dif2(vars);
    vars=dif(vars);
  end;

  length contrast $19;
  contrast=catx(' ',time,'-',lag(time));
  if contrast in('Control - Baseline','Baseline - post') then output;

  if time='Control' and lag2(time)='post' then do;
    contrast='Control - post';
    do over vars;
      vars=diftwo;
    end;
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;
data want  (drop=time);
  array var  var1-var4;

  do contrast='Control - Baseline','Control - post','Baseline - post';

    do until (dif(e1) or dif(e2) or dif(e3));
      if contrast='Control - Baseline' then do; 
        set have (where=(time='Baseline')) have (where=(time='Control'))  end=e1; by subject; 
      end; else
      if contrast='Control - post'     then do; 
        set have (where=(time='post'))     have (where=(time='Control'))  end=e2; by subject; 
      end; else
      if contrast='Baseline - post'    then do; 
        set have (where=(time='post'))     have (where=(time='Baseline')) end=e3; by subject; 
      end; 

      do over var;
        var=dif(var);
      end;
      if last.subject then output; 
    end;
  end;  
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Feb 2022 15:24:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substracting-variables-at-different-timepoints/m-p/797389#M287490</guid>
      <dc:creator>Job04</dc:creator>
      <dc:date>2022-02-19T15:24:21Z</dc:date>
    </item>
  </channel>
</rss>

