<?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 How to sum to certain weeks horizontally in a row in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-sum-to-certain-weeks-horizontally-in-a-row/m-p/211757#M52311</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;We have a question about how to sum horizontally in SAS.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif; background-position: initial;"&gt;The data exists in SAS format, and we know the names of the variables.&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;Our dataset contains several horizontal rows, each one representing a person.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;Each column represents one week and all the week-variables are numeric (the time period is from year 1999-2001, thus the total number of columns/weeks is 52*3 = 156). &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;All observations contain one of the following values: “1” and “0”. &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;We would really appreciate if anyone would like to help us with a SAS code enabling us to sum horizontally in a row (i.e. a time period for each person of the dataset) and thereby generating a variable, &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;which counts the sum of week number 25 and 26 from the first week you meet the value “1”. Meaning that the code from the first time you meet “1” counts 25 and 26 weeks ahead and generates a variable, which contains the sum of those two weeks. An example is a “1” observation in week 12 in 1999, the new variable should only count 25 and 26 weeks ahead, and thereby only summing week 37 and 38 in 1999. The new variable (sum variable) can either take the value 0, 1 or 2 depending on whether the “1” value is present in zero, one week or both weeks (week 37 and 38). It doesn’t matter which values the weeks between week 1 and 25 contains (“0” or “1”). &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;The first observed “1” has to be placed in a week in the period year 1999-2001, but the following observations (week number 25 and 26) are also allowed to be places outside the period (e.g. in year 2002), as long as the first observation is placed in a week between year 1999-2001.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;Thank you in advance.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;Best regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;Maria and Sissel&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 08 May 2015 08:24:49 GMT</pubDate>
    <dc:creator>Maria_Sissel</dc:creator>
    <dc:date>2015-05-08T08:24:49Z</dc:date>
    <item>
      <title>How to sum to certain weeks horizontally in a row</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-sum-to-certain-weeks-horizontally-in-a-row/m-p/211757#M52311</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;We have a question about how to sum horizontally in SAS.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif; background-position: initial;"&gt;The data exists in SAS format, and we know the names of the variables.&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;Our dataset contains several horizontal rows, each one representing a person.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;Each column represents one week and all the week-variables are numeric (the time period is from year 1999-2001, thus the total number of columns/weeks is 52*3 = 156). &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;All observations contain one of the following values: “1” and “0”. &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;We would really appreciate if anyone would like to help us with a SAS code enabling us to sum horizontally in a row (i.e. a time period for each person of the dataset) and thereby generating a variable, &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;which counts the sum of week number 25 and 26 from the first week you meet the value “1”. Meaning that the code from the first time you meet “1” counts 25 and 26 weeks ahead and generates a variable, which contains the sum of those two weeks. An example is a “1” observation in week 12 in 1999, the new variable should only count 25 and 26 weeks ahead, and thereby only summing week 37 and 38 in 1999. The new variable (sum variable) can either take the value 0, 1 or 2 depending on whether the “1” value is present in zero, one week or both weeks (week 37 and 38). It doesn’t matter which values the weeks between week 1 and 25 contains (“0” or “1”). &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;The first observed “1” has to be placed in a week in the period year 1999-2001, but the following observations (week number 25 and 26) are also allowed to be places outside the period (e.g. in year 2002), as long as the first observation is placed in a week between year 1999-2001.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;Thank you in advance.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN lang="EN-US" style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;Best regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;Maria and Sissel&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 May 2015 08:24:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-sum-to-certain-weeks-horizontally-in-a-row/m-p/211757#M52311</guid>
      <dc:creator>Maria_Sissel</dc:creator>
      <dc:date>2015-05-08T08:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum to certain weeks horizontally in a row</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-sum-to-certain-weeks-horizontally-in-a-row/m-p/211758#M52312</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, this is untested code as no test data:&lt;/P&gt;&lt;P&gt;data want;&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; array col{156};&amp;nbsp; /* Assumes each of the columns is COL1, COL2, COL156 */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result=sum(of col{*});&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;run; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 May 2015 08:31:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-sum-to-certain-weeks-horizontally-in-a-row/m-p/211758#M52312</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-05-08T08:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum to certain weeks horizontally in a row</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-sum-to-certain-weeks-horizontally-in-a-row/m-p/211759#M52313</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assuming all numeric variables:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;data want;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array col{156} col1 - col156;&amp;nbsp; /* Assumes each of the columns is COL1, COL2, COL156 */&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; first_1=whichn(1, of col(*));*find the first 1;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if first_1+25&amp;lt;dim(col) then&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp; /*make sure you're not going past the end of the data*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; indicator=col(first_1+25) + col(first_1+26); /*add the 25th &amp;amp; 26th data points past first 1 */&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 May 2015 08:49:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-sum-to-certain-weeks-horizontally-in-a-row/m-p/211759#M52313</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-05-08T08:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum to certain weeks horizontally in a row</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-sum-to-certain-weeks-horizontally-in-a-row/m-p/211760#M52314</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There you go reading the whole question again &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 May 2015 09:42:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-sum-to-certain-weeks-horizontally-in-a-row/m-p/211760#M52314</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-05-08T09:42:09Z</dc:date>
    </item>
  </channel>
</rss>

