<?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 variable values in increments in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/adding-variable-values-in-increments/m-p/470037#M285612</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/162744"&gt;@klinz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am working on a dosing project where I need to add the concentration at time 12 to the concentration at time 0, concentration at time 12.25 to concentration at .25, concentration at 12.5 to the concentration at .5 .. etc. etc. etc.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following is code that I have come up with so far..&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test2;&lt;BR /&gt;set test;&lt;BR /&gt;if time &amp;gt;= 12 then do;&lt;BR /&gt;conc2=conc+5;&amp;nbsp; &amp;nbsp; &amp;nbsp; /*i need to add the concentration from 12 hours prior to the current concentration, '5' is my placeholder*/&lt;BR /&gt;end;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/*i.e. conc2 at hour 13 = current concentration at hour 13 + concentration at hour 1*/&lt;BR /&gt;else conc2=conc;&amp;nbsp; &amp;nbsp; /*all concentrations prior to hour 12 are to remain the same*/&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this may be an easy fix, but I've been looking at it so long i'm going cross eyed&lt;/P&gt;
&lt;P&gt;any help would be appreciated, thanks in advance&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What does your TEST data set look like? I would expect that there is one measurement for CONC at each time point and they are on different rows of the data. Which would mean that you may want to use a different approach such as LAG to find the appropriate previous 12 hour measure.&lt;/P&gt;
&lt;P&gt;And if there are multiple days involved then an actual date might be helpful.&lt;/P&gt;</description>
    <pubDate>Wed, 13 Jun 2018 18:22:13 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-06-13T18:22:13Z</dc:date>
    <item>
      <title>adding variable values in increments</title>
      <link>https://communities.sas.com/t5/SAS-Programming/adding-variable-values-in-increments/m-p/470020#M285610</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on a dosing project where I need to add the concentration at time 12 to the concentration at time 0, concentration at time 12.25 to concentration at .25, concentration at 12.5 to the concentration at .5 .. etc. etc. etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following is code that I have come up with so far..&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test2;&lt;BR /&gt;set test;&lt;BR /&gt;if time &amp;gt;= 12 then do;&lt;BR /&gt;conc2=conc+5;&amp;nbsp; &amp;nbsp; &amp;nbsp; /*i need to add the concentration from 12 hours prior to the current concentration, '5' is my placeholder*/&lt;BR /&gt;end;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/*i.e. conc2 at hour 13 = current concentration at hour 13 + concentration at hour 1*/&lt;BR /&gt;else conc2=conc;&amp;nbsp; &amp;nbsp; /*all concentrations prior to hour 12 are to remain the same*/&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this may be an easy fix, but I've been looking at it so long i'm going cross eyed&lt;/P&gt;&lt;P&gt;any help would be appreciated, thanks in advance&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2018 17:47:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/adding-variable-values-in-increments/m-p/470020#M285610</guid>
      <dc:creator>klinz</dc:creator>
      <dc:date>2018-06-13T17:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: adding variable values in increments</title>
      <link>https://communities.sas.com/t5/SAS-Programming/adding-variable-values-in-increments/m-p/470033#M285611</link>
      <description>&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;set ....;&lt;/P&gt;&lt;P&gt;if time ge 12 then do;&lt;/P&gt;&lt;P&gt;timept=2;&lt;/P&gt;&lt;P&gt;newt=time-12;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;else do;&lt;/P&gt;&lt;P&gt;timept=1;&lt;/P&gt;&lt;P&gt;newt=time;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=test;&lt;/P&gt;&lt;P&gt;by newt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc transpose data=test out=test_t prefix=time;&lt;/P&gt;&lt;P&gt;var conc;&lt;/P&gt;&lt;P&gt;id timept;&lt;/P&gt;&lt;P&gt;by newt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test2;&lt;/P&gt;&lt;P&gt;set test_t;&lt;/P&gt;&lt;P&gt;x=time1+tim2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;something like this maybe&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2018 18:12:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/adding-variable-values-in-increments/m-p/470033#M285611</guid>
      <dc:creator>pau13rown</dc:creator>
      <dc:date>2018-06-13T18:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: adding variable values in increments</title>
      <link>https://communities.sas.com/t5/SAS-Programming/adding-variable-values-in-increments/m-p/470037#M285612</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/162744"&gt;@klinz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am working on a dosing project where I need to add the concentration at time 12 to the concentration at time 0, concentration at time 12.25 to concentration at .25, concentration at 12.5 to the concentration at .5 .. etc. etc. etc.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following is code that I have come up with so far..&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test2;&lt;BR /&gt;set test;&lt;BR /&gt;if time &amp;gt;= 12 then do;&lt;BR /&gt;conc2=conc+5;&amp;nbsp; &amp;nbsp; &amp;nbsp; /*i need to add the concentration from 12 hours prior to the current concentration, '5' is my placeholder*/&lt;BR /&gt;end;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/*i.e. conc2 at hour 13 = current concentration at hour 13 + concentration at hour 1*/&lt;BR /&gt;else conc2=conc;&amp;nbsp; &amp;nbsp; /*all concentrations prior to hour 12 are to remain the same*/&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this may be an easy fix, but I've been looking at it so long i'm going cross eyed&lt;/P&gt;
&lt;P&gt;any help would be appreciated, thanks in advance&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What does your TEST data set look like? I would expect that there is one measurement for CONC at each time point and they are on different rows of the data. Which would mean that you may want to use a different approach such as LAG to find the appropriate previous 12 hour measure.&lt;/P&gt;
&lt;P&gt;And if there are multiple days involved then an actual date might be helpful.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2018 18:22:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/adding-variable-values-in-increments/m-p/470037#M285612</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-13T18:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: adding variable values in increments</title>
      <link>https://communities.sas.com/t5/SAS-Programming/adding-variable-values-in-increments/m-p/470043#M285613</link>
      <description>yes that's right, i have a concentration for each time point..&lt;BR /&gt;I have not used LAG before.. any suggestions for implementation?</description>
      <pubDate>Wed, 13 Jun 2018 18:36:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/adding-variable-values-in-increments/m-p/470043#M285613</guid>
      <dc:creator>klinz</dc:creator>
      <dc:date>2018-06-13T18:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: adding variable values in increments</title>
      <link>https://communities.sas.com/t5/SAS-Programming/adding-variable-values-in-increments/m-p/470044#M285614</link>
      <description>playing with this to see if it can work..&lt;BR /&gt;I'm keen on the thought of making a new variable, but I think the 'transpose' step is not working how I need it to..</description>
      <pubDate>Wed, 13 Jun 2018 18:37:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/adding-variable-values-in-increments/m-p/470044#M285614</guid>
      <dc:creator>klinz</dc:creator>
      <dc:date>2018-06-13T18:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: adding variable values in increments</title>
      <link>https://communities.sas.com/t5/SAS-Programming/adding-variable-values-in-increments/m-p/470054#M285615</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input time conc;
datalines;
0	1
0.5	2
1	3
1.5	4
2	5
2.5	6
3	7
3.5	8
4	9
4.5	10
5	11
5.5	12
6	13
6.5	14
7	15
7.5	16
8	17
8.5	18
9	19
9.5	20
10	21
10.5	22
11	23
11.5	24
12	25
12.5	26
13	27
13.5	28
14	29
14.5	30
15	31
15.5	32
16	33
16.5	34
17	35
17.5	36
18	37
18.5	38
19	39
19.5	40
20	41
;

proc sql;
create table newTest as
select 
    a.time,
    a.conc,
    a.conc + b.conc as newConc
from 
    test as a left join
    test as b on b.time = a.time + 12;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Jun 2018 19:07:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/adding-variable-values-in-increments/m-p/470054#M285615</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-06-13T19:07:37Z</dc:date>
    </item>
  </channel>
</rss>

