<?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: Creating new variable from vertical sums. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-variable-from-vertical-sums/m-p/129058#M26353</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a bunch for your reply, Astounding!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Sep 2012 16:51:14 GMT</pubDate>
    <dc:creator>Julle</dc:creator>
    <dc:date>2012-09-25T16:51:14Z</dc:date>
    <item>
      <title>Creating new variable from vertical sums.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-variable-from-vertical-sums/m-p/129056#M26351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guys! &lt;/P&gt;&lt;P&gt;I'm working on my master-thesis, but I've gotten stuck in the programming-stage. Could really use some help from fellow sas-programmers. Thanks in advance!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically what I'm trying to do is to write a program calculating the expected risks of small bowel cancer in terms of incidence per person, starting year in risk population, age when entering the riskpopulation and the total years spent in the population. These expected risks will later on be used to construct SIR's. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Varibles&lt;/P&gt;&lt;P&gt;-------------------------------------&lt;/P&gt;&lt;P&gt;year (range: 1970 to 2010)&lt;/P&gt;&lt;P&gt;gender (male,female)&lt;/P&gt;&lt;P&gt;age (range: 0 to 100)&lt;/P&gt;&lt;P&gt;incidence per person&lt;/P&gt;&lt;P&gt;years til event/end of follow up ( 1-41 for 1970, 1-40 for 1971 etc..)&lt;/P&gt;&lt;P&gt;---------------------------------------&lt;/P&gt;&lt;P&gt;thus,&amp;nbsp; resulting dataset has 200 000+ rows/kombinations&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now what I want is to create a new variable called 'risk' which sums the incidences across rows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;Lets say a female enters the population in year 1975 at the age of 30 and spends a total of 3 years in the population. &lt;/P&gt;&lt;P&gt;The 'risk'-variable would then be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Risk(female,1970,30,3)=incidence(female, 1975, 30)+ incidence(female, 1976, 31) + incidence(female, 1977, 32)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I write this? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 15:15:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-new-variable-from-vertical-sums/m-p/129056#M26351</guid>
      <dc:creator>Julle</dc:creator>
      <dc:date>2012-09-24T15:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new variable from vertical sums.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-variable-from-vertical-sums/m-p/129057#M26352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Julle,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is a relatively easy problem.&amp;nbsp; PROC SUMMARY will do the job, and plenty of people will help you with it.&amp;nbsp; Here are a couple of tasks that fall to you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First, there must be another variable, such as ID in your data set.&amp;nbsp; Otherwise, how could you tell which observations belong to the same person?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The final result will be a summarized data set with one observation per person.&amp;nbsp; So depending on the programming approach used, it probably will end up being a separate data set rather than having the summary statistics attached to every incoming observation.&amp;nbsp; If you have preferences about what the result should look like, let us know.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally, can we assume that every observation in the incoming data represents an incidence year?&amp;nbsp; If not, how do we know which years should be included in the summary and which ones omitted?&lt;/P&gt;&lt;P&gt;The programming is straightforward, something like this (depending on the answers to these questions):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc summary data=have nway;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; class id;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; var year incidence;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; output out=stats (keep=id risk first_year last_year) sum(incidence)=risk min(year)=first_year max(year)=last_year;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You would still have to use first_year and last_year to compute duration later.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 16:11:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-new-variable-from-vertical-sums/m-p/129057#M26352</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-09-24T16:11:56Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new variable from vertical sums.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-variable-from-vertical-sums/m-p/129058#M26353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a bunch for your reply, Astounding!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Sep 2012 16:51:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-new-variable-from-vertical-sums/m-p/129058#M26353</guid>
      <dc:creator>Julle</dc:creator>
      <dc:date>2012-09-25T16:51:14Z</dc:date>
    </item>
  </channel>
</rss>

