<?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: Compute summary variables in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Compute-summary-variables-in-SAS/m-p/651573#M195503</link>
    <description>&lt;P&gt;Does this work for you?&lt;/P&gt;
&lt;PRE&gt;data have ;
   input study_id con_tot con1 con2 con3 con4 con5 con6 con7 con8 ;
   cards ;
1001 8 1 1 1 1 1 2 2 1		
1002 2 1 2 . . . . . .		
;
run ;

data want ;
   set have ;
   array _con (*) con1 - con8 ;
   do _n_ = 1 to dim(_con) ;
      md_tot = sum(md_tot,(_con(_n_)=1)) ;
      sw_tot = sum(sw_tot,(_con(_n_)=2)) ;
   end ;
run ;&lt;/PRE&gt;</description>
    <pubDate>Thu, 28 May 2020 22:37:18 GMT</pubDate>
    <dc:creator>biopharma</dc:creator>
    <dc:date>2020-05-28T22:37:18Z</dc:date>
    <item>
      <title>Compute summary variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-summary-variables-in-SAS/m-p/651570#M195502</link>
      <description>&lt;P&gt;Hi Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&amp;nbsp;hoping you could help me determine how to create and compute 2 new summary variables that capture the total number of contacts based on provider type (MD or Social worker (SW)). The 2 new variables&amp;nbsp;need to be continuous. As you can see in the table below, study_id 1001 received a total of 8 contacts during the follow-up period: 6 MD &amp;amp; 2 SW. I would&amp;nbsp;to write&amp;nbsp;a SAS code to create and compute the 2 variables (MD_tot and SW_tot). Please help or point me in the right direction.&lt;/P&gt;&lt;P&gt;Thanks so much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Data set:&lt;/STRONG&gt; 2250 observations&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Total # variables in data set&lt;/STRONG&gt;: 138&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Variables related to this question:&lt;/STRONG&gt; (in table below)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Variables related to this question are coded as&lt;/STRONG&gt;: Con1-Con8 (1 =MD, 2 =SW; binary)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;New variables I'd like to create:&lt;/STRONG&gt; count of total Con1-Con8 by provider contact. These will be continuous variables&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sample subset of data set&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;study_id&lt;/TD&gt;&lt;TD&gt;con_tot&lt;/TD&gt;&lt;TD&gt;con1&lt;/TD&gt;&lt;TD&gt;con2&lt;/TD&gt;&lt;TD&gt;con3&lt;/TD&gt;&lt;TD&gt;con4&lt;/TD&gt;&lt;TD&gt;con5&lt;/TD&gt;&lt;TD&gt;con6&lt;/TD&gt;&lt;TD&gt;con7&lt;/TD&gt;&lt;TD&gt;con8&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;MD_tot&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;SW_tot&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1001&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;?&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;?&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1002&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;?&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;?&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 May 2020 22:17:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-summary-variables-in-SAS/m-p/651570#M195502</guid>
      <dc:creator>Kimberly09</dc:creator>
      <dc:date>2020-05-28T22:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: Compute summary variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-summary-variables-in-SAS/m-p/651573#M195503</link>
      <description>&lt;P&gt;Does this work for you?&lt;/P&gt;
&lt;PRE&gt;data have ;
   input study_id con_tot con1 con2 con3 con4 con5 con6 con7 con8 ;
   cards ;
1001 8 1 1 1 1 1 2 2 1		
1002 2 1 2 . . . . . .		
;
run ;

data want ;
   set have ;
   array _con (*) con1 - con8 ;
   do _n_ = 1 to dim(_con) ;
      md_tot = sum(md_tot,(_con(_n_)=1)) ;
      sw_tot = sum(sw_tot,(_con(_n_)=2)) ;
   end ;
run ;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 May 2020 22:37:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-summary-variables-in-SAS/m-p/651573#M195503</guid>
      <dc:creator>biopharma</dc:creator>
      <dc:date>2020-05-28T22:37:18Z</dc:date>
    </item>
    <item>
      <title>Re: Compute summary variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-summary-variables-in-SAS/m-p/651578#M195504</link>
      <description>&lt;P&gt;Or:&lt;/P&gt;
&lt;PRE&gt;data WANT;
   set HAVE ;
   MD_TOT = lengthn(compress(catt(of CON1-CON8),' .2'));
   SW_TOT = lengthn(compress(catt(of CON1-CON8),' .1'));  &lt;BR /&gt;run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 May 2020 23:00:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-summary-variables-in-SAS/m-p/651578#M195504</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-05-28T23:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: Compute summary variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-summary-variables-in-SAS/m-p/651596#M195515</link>
      <description>The code works like a charm! Thanks so much for your help.&lt;BR /&gt;</description>
      <pubDate>Thu, 28 May 2020 23:45:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-summary-variables-in-SAS/m-p/651596#M195515</guid>
      <dc:creator>Kimberly09</dc:creator>
      <dc:date>2020-05-28T23:45:26Z</dc:date>
    </item>
    <item>
      <title>Re: Compute summary variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compute-summary-variables-in-SAS/m-p/651597#M195516</link>
      <description>Thanks so much! This works perfectly!</description>
      <pubDate>Thu, 28 May 2020 23:49:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compute-summary-variables-in-SAS/m-p/651597#M195516</guid>
      <dc:creator>Kimberly09</dc:creator>
      <dc:date>2020-05-28T23:49:15Z</dc:date>
    </item>
  </channel>
</rss>

