<?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 add a row value to other values in the same row in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-row-value-to-other-values-in-the-same-row/m-p/608456#M177088</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/270457"&gt;@unison&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi there, something like this solve your problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id wait_time pts_1 pts_2 pts_3;
datalines;
1 12.85 1.67 2 1.5
;
run;

data want;
set have;
array pts pts:;
do over pts;
pts+wait_time;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;-unison&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The statement&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;pts+wait_time;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;will work for this problem, as stated.&amp;nbsp; But I would NOT recommend it.&amp;nbsp; This is a SAS SUMming statement, which means (1) is will accumulated values over consecutive observations (not a problem here), and (2) will not always produce the same results as&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;pts=pts+wait_time;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Take a look at the results for observations 3 and 4 below, where there are missing values introduced:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
input id wait_time pts_1 pts_2 pts_3; 
datalines; 
1 12.85 1.67 2 1.5 
2 11.85 1.67 2 1.5
3 10.85    . 2 1.5 
4     . 1.67 2 1.5
run; 
data want1; 
  set have; 
  array pts pts:; 
  do over pts; 
    pts+wait_time; 
  end; 
run; 
data want2; 
  set have; 
  array pts pts:; 
  do over pts; 
    pts=pts+wait_time; 
  end; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 30 Nov 2019 16:02:33 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2019-11-30T16:02:33Z</dc:date>
    <item>
      <title>How to add a row value to other values in the same row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-row-value-to-other-values-in-the-same-row/m-p/608451#M177083</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I’m working on a rather large data set that I need to add one value to several hundred other values in the same row.&lt;BR /&gt;&lt;BR /&gt;And example would be:&lt;BR /&gt;&lt;BR /&gt;ID Wait Time Pts 1 Pts 2 Pts 3 etc.&lt;BR /&gt;1 12.85 1.67 2 1.5.&lt;BR /&gt;&lt;BR /&gt;Output&lt;BR /&gt;14.52 14.85 14.35&lt;BR /&gt;&lt;BR /&gt;There has to be an easier way to do this without manually inputting formulas one by one for each value.&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Sat, 30 Nov 2019 15:47:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-row-value-to-other-values-in-the-same-row/m-p/608451#M177083</guid>
      <dc:creator>Gator77</dc:creator>
      <dc:date>2019-11-30T15:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a row value to other values in the same row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-row-value-to-other-values-in-the-same-row/m-p/608453#M177085</link>
      <description>&lt;P&gt;Hi there, something like this solve your problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id wait_time pts_1 pts_2 pts_3;
datalines;
1 12.85 1.67 2 1.5
;
run;

data want;
set have;
array pts pts:;
do over pts;
pts=pts+wait_time;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;-unison&lt;/P&gt;</description>
      <pubDate>Sat, 30 Nov 2019 16:09:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-row-value-to-other-values-in-the-same-row/m-p/608453#M177085</guid>
      <dc:creator>unison</dc:creator>
      <dc:date>2019-11-30T16:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a row value to other values in the same row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-row-value-to-other-values-in-the-same-row/m-p/608456#M177088</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/270457"&gt;@unison&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi there, something like this solve your problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id wait_time pts_1 pts_2 pts_3;
datalines;
1 12.85 1.67 2 1.5
;
run;

data want;
set have;
array pts pts:;
do over pts;
pts+wait_time;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;-unison&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The statement&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;pts+wait_time;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;will work for this problem, as stated.&amp;nbsp; But I would NOT recommend it.&amp;nbsp; This is a SAS SUMming statement, which means (1) is will accumulated values over consecutive observations (not a problem here), and (2) will not always produce the same results as&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;pts=pts+wait_time;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Take a look at the results for observations 3 and 4 below, where there are missing values introduced:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
input id wait_time pts_1 pts_2 pts_3; 
datalines; 
1 12.85 1.67 2 1.5 
2 11.85 1.67 2 1.5
3 10.85    . 2 1.5 
4     . 1.67 2 1.5
run; 
data want1; 
  set have; 
  array pts pts:; 
  do over pts; 
    pts+wait_time; 
  end; 
run; 
data want2; 
  set have; 
  array pts pts:; 
  do over pts; 
    pts=pts+wait_time; 
  end; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Nov 2019 16:02:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-row-value-to-other-values-in-the-same-row/m-p/608456#M177088</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-11-30T16:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a row value to other values in the same row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-row-value-to-other-values-in-the-same-row/m-p/608476#M177097</link>
      <description>&lt;P&gt;Arrays are the recommend approach here.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Here's a tutorial on using Arrays in SAS&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-arrays/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-arrays/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/301775"&gt;@Gator77&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I’m working on a rather large data set that I need to add one value to several hundred other values in the same row.&lt;BR /&gt;&lt;BR /&gt;And example would be:&lt;BR /&gt;&lt;BR /&gt;ID Wait Time Pts 1 Pts 2 Pts 3 etc.&lt;BR /&gt;1 12.85 1.67 2 1.5.&lt;BR /&gt;&lt;BR /&gt;Output&lt;BR /&gt;14.52 14.85 14.35&lt;BR /&gt;&lt;BR /&gt;There has to be an easier way to do this without manually inputting formulas one by one for each value.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Nov 2019 19:11:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-row-value-to-other-values-in-the-same-row/m-p/608476#M177097</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-30T19:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a row value to other values in the same row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-row-value-to-other-values-in-the-same-row/m-p/608869#M177242</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/301775"&gt;@Gator77&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I’m working on a rather large data set that I need to add one value to several hundred other values in the same row.&lt;BR /&gt;&lt;BR /&gt;And example would be:&lt;BR /&gt;&lt;BR /&gt;ID Wait Time Pts 1 Pts 2 Pts 3 etc.&lt;BR /&gt;1 12.85 1.67 2 1.5.&lt;BR /&gt;&lt;BR /&gt;Output&lt;BR /&gt;14.52 14.85 14.35&lt;BR /&gt;&lt;BR /&gt;There has to be an easier way to do this without manually inputting formulas one by one for each value.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think that you need to walk us through the explicit formula you are using. The input data has 5 values and the output only 3. So which variables are used and how to get that output??&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2019 21:43:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-row-value-to-other-values-in-the-same-row/m-p/608869#M177242</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-12-02T21:43:57Z</dc:date>
    </item>
  </channel>
</rss>

