<?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: Array vs macro for calculating mean duration of time experiencing an event in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Array-vs-macro-for-calculating-mean-duration-of-time/m-p/82912#M23786</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Apr 2013 02:28:43 GMT</pubDate>
    <dc:creator>ginak</dc:creator>
    <dc:date>2013-04-17T02:28:43Z</dc:date>
    <item>
      <title>Array vs macro for calculating mean duration of time experiencing an event</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-vs-macro-for-calculating-mean-duration-of-time/m-p/82910#M23784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;Hello,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;My data set has the following variables:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;event1 t1a0 t1a1 t1a2 .... t1a18 event2 t2a0 t2a1 t2a2 t2a3 .... t2a18&amp;nbsp; ......... event20 t20a0 t20a1 t20a2 t20a3 ..... t20a18&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;So each variable is binary. the child either did or did not receive event 1 (1=yes, 0=no), ..., the child either did or did not receive event 20 (1=yes, 0=no).&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;the child either did or did not receive event1 at age0 (t1a0=1 if yes, t1a0=0 if no),&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;the child either did or did not receive event1 at age1 (t1a1=1 if yes, t1a1=0 if no),&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;the child either did or did not receive event1 at age18 (t1a18=1 if yes, t1a18=0 if no),&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;the child either did or did not receive event20 at age0 (t20a0=1 if yes, t20a0=0 if no),&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;the child either did or did not receive event20 at age1 (t20a1=1 if yes, t20a1=0 if no),&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;the child either did or did not receive event20 at age18 (t20a18=1 if yes, t20a18=0 if no),&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;My question is this - I would like to present the mean duration of years the child experienced each of the 20 events and the standard deviation, as well as the number of kids who experienced each type of event and the percentage of those who did so and put together in a nice table as such:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" cellpadding="0" cellspacing="0" style="border: none; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;TBODY style="font-style: inherit; font-family: inherit;"&gt;&lt;TR style="border: 0px; font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding: 1.5pt; border: none; font-style: inherit; font-family: inherit; background-color: #6690bc;"&gt;&lt;P align="center" style="margin: 0px 0px 1.5pt; font-style: inherit; font-family: inherit; text-align: center;"&gt;&lt;STRONG style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif; color: white;"&gt;Header 1&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="padding: 1.5pt; border: none; font-style: inherit; font-family: inherit; background-color: #6690bc;"&gt;&lt;P align="center" style="margin: 0px 0px 1.5pt; font-style: inherit; font-family: inherit; text-align: center;"&gt;&lt;STRONG style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif; color: white;"&gt;Header 2&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="padding: 1.5pt; border: none; font-style: inherit; font-family: inherit; background-color: #6690bc;"&gt;&lt;P align="center" style="margin: 0px 0px 1.5pt; font-style: inherit; font-family: inherit; text-align: center;"&gt;&lt;STRONG style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif; color: white;"&gt;Header 3&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: 0px; font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding: 1.5pt; border: none; font-style: inherit; font-family: inherit;"&gt;&lt;P style="margin: 0px 0px 1.5pt; font-style: inherit; font-family: inherit;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;event type&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="padding: 1.5pt; border: none; font-style: inherit; font-family: inherit;"&gt;&lt;P style="margin: 0px 0px 1.5pt; font-style: inherit; font-family: inherit;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;endorsed: % (n)&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="padding: 1.5pt; border: none; font-style: inherit; font-family: inherit;"&gt;&lt;P style="margin: 0px 0px 1.5pt; font-style: inherit; font-family: inherit;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; duration: mean (SD)&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: 0px; font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding: 1.5pt; border: none; font-style: inherit; font-family: inherit;"&gt;&lt;P style="margin: 0px 0px 1.5pt; font-style: inherit; font-family: inherit;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;event 1&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="padding: 1.5pt; border: none; font-style: inherit; font-family: inherit;"&gt;&lt;P style="margin: 0px 0px 1.5pt; font-style: inherit; font-family: inherit;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;55.44 (2550)&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="padding: 1.5pt; border: none; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.89 (1.94)&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: 0px; font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding: 1.5pt; border: none; font-style: inherit; font-family: inherit;"&gt;&lt;SPAN style="font-size: 10pt; font-style: inherit; margin: 0 0 1.5pt; font-family: Arial, sans-serif;"&gt;event 2&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 1.5pt; border: none; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;etc.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; etc&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: 0px; font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding: 1.5pt; border: none; font-style: inherit; font-family: inherit;"&gt;&lt;SPAN style="font-size: 10pt; font-style: inherit; margin: 0 0 1.5pt; font-family: Arial, sans-serif;"&gt;......&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 1.5pt; border: none; font-style: inherit; font-family: inherit;"&gt;&lt;SPAN style="font-size: 10pt; font-style: inherit; margin: 0 0 1.5pt; font-family: Arial, sans-serif;"&gt;.....&amp;nbsp; &lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 1.5pt; border: none; font-style: inherit; font-family: inherit;"&gt;&lt;SPAN style="font-size: 10pt; font-style: inherit; margin: 0 0 1.5pt; font-family: Arial, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: 0px; font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding: 1.5pt; border: none; font-style: inherit; font-family: inherit;"&gt;&lt;SPAN style="font-size: 10pt; font-style: inherit; margin: 0 0 1.5pt; font-family: Arial, sans-serif;"&gt;event 20&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 1.5pt; border: none; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;etc &lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; etc&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;I was able to calculate the % and n endorsed for each event. However, I'm not sure how to calculate the mean duration of years that each child experienced the event. For example, the child may have had experienced event 1 at ages 0, 1, 5, 6, 16, 17, 18 and event 5 at ages 0, 5, 6, 7. Each child can experience multiple events.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;I was trying to do an array but I don't think my way is correct...&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;Given that the names of the variables are similar (t[event #]a[age]), how could I calculate this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;For event 2 i could calculate the # of years each child experienced the event as&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: Arial, sans-serif;"&gt;duration2= sum(of t2:);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;But now I want to do this for each event. I dont' want to make 20 arrays b/c there are 20 events, and in my array statement I'd have 20*18=360 variables which is too long.. any suggestions as to how I could calculate the mean duration of each event and the standard deviation? I can clarify if this is too confusing..&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;And then what, in your opinion is the best way to present this in a table? I'd like to just ods output it, or use ods trace to obtain values to put into a proc report.&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Thanks,&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Gina&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jan 2013 01:40:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-vs-macro-for-calculating-mean-duration-of-time/m-p/82910#M23784</guid>
      <dc:creator>ginak</dc:creator>
      <dc:date>2013-01-23T01:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: Array vs macro for calculating mean duration of time experiencing an event</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-vs-macro-for-calculating-mean-duration-of-time/m-p/82911#M23785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not easy to suggest something without a sample dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just a starter, important note: event numbers must start with leading zeros&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; length kid 8&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Event01 Event02 Event03 $ 10&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t01a1-t01a10 t02a1-t02a10 t03a1-t03a10 8;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; drop i;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array t01 t01:;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array t02 t02:;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array t03 t03:;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Event01 = 'one';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Event02 = 'two';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Event03 = 'three';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do kid = 1 to 4;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i = 1 to dim(t01);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t01&lt;I&gt; = mod(int(ranuni(0) * 415547409), 2);&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t02&lt;I&gt; = mod(int(ranuni(0) * 345345), 2);&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t03&lt;I&gt; = mod(int(ranuni(0) * 94532), 2);&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro bob;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select substr(Name, 5) into :VarList separated by ' '&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from sashelp.vcolumn&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where libname = 'WORK' and memname = 'TEST' and Name like 'Event%';&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* VarList contains t01 t02 t03 ... */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data work.NextStep;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set work.test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; keep kid event: duration_t:;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* the loop creates one sum-function for each event; */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do i = 1 %to %sysfunc(countw(&amp;amp;VarList));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let var = %scan(&amp;amp;VarList, &amp;amp;i, %str( ));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; duration_&amp;amp;var = sum(of &amp;amp;var:);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%bob;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now transpose work.NextStep, so that it contains one observation for each kid and event. Afterwards required statistics can be calculated by the usual route (proc means, maybe tabulate).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jan 2013 09:26:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-vs-macro-for-calculating-mean-duration-of-time/m-p/82911#M23785</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2013-01-24T09:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: Array vs macro for calculating mean duration of time experiencing an event</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-vs-macro-for-calculating-mean-duration-of-time/m-p/82912#M23786</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Apr 2013 02:28:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-vs-macro-for-calculating-mean-duration-of-time/m-p/82912#M23786</guid>
      <dc:creator>ginak</dc:creator>
      <dc:date>2013-04-17T02:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: Array vs macro for calculating mean duration of time experiencing an event</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-vs-macro-for-calculating-mean-duration-of-time/m-p/82913#M23787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure whether it is what you need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data test;
input event1 t1a0-t1a18;
cards;
1 0 0 1 1 0 1 0 1 1 1 1 1 0 0 0 0 1 1 1
;
run;

data temp;
 set test;
array x{*} _all_;
length _name $ 40;
do i=1 to dim(x);
_name=vname(x{i});
value=x{i};
output;
end;
run;
data temp;
 set temp;
 length name $ 40;
 retain name;
 if _name eq: 'event' then do; name=_name;delete;end;
proc sql;
create table want as
 select name, catx(' ',sum(value=1)/count(*),'(', count(*),')') as endorse,catx(' ',mean(value),'(',std(value),')') as mean_std
&amp;nbsp; from temp
&amp;nbsp;&amp;nbsp;&amp;nbsp; group by name;
quit;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Apr 2013 08:28:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-vs-macro-for-calculating-mean-duration-of-time/m-p/82913#M23787</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2013-04-20T08:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: Array vs macro for calculating mean duration of time experiencing an event</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-vs-macro-for-calculating-mean-duration-of-time/m-p/82914#M23788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, you helped me a lot &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; I am a bit of a "newbie" when it comes to SAS and so my programming skills aren't that advanced.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Apr 2013 19:15:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-vs-macro-for-calculating-mean-duration-of-time/m-p/82914#M23788</guid>
      <dc:creator>ginak</dc:creator>
      <dc:date>2013-04-22T19:15:03Z</dc:date>
    </item>
  </channel>
</rss>

