<?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 DOW LOOP to merge summary statistics in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/DOW-LOOP-to-merge-summary-statistics/m-p/254481#M48542</link>
    <description>&lt;P&gt;&amp;nbsp;How can get the outptut (remerging summary statistics to the original data) as from PROC SQL code using DOUBLE DOW LOOP (pseudo code below)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	select name,sex,age,height,weight,avg(age) as avg_age
		from sashelp.class 
			group by sex;
quit;

data test;
	do until(last.sex);
		set sashelp.class;
		by sex notsorted;
	end;

	/**** some code to get avergae age ****/

	do until(last.sex);
		set sashelp.class;
		by sex notsorted;
		output;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Mar 2016 16:29:47 GMT</pubDate>
    <dc:creator>SAS_inquisitive</dc:creator>
    <dc:date>2016-03-04T16:29:47Z</dc:date>
    <item>
      <title>DOW LOOP to merge summary statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DOW-LOOP-to-merge-summary-statistics/m-p/254481#M48542</link>
      <description>&lt;P&gt;&amp;nbsp;How can get the outptut (remerging summary statistics to the original data) as from PROC SQL code using DOUBLE DOW LOOP (pseudo code below)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	select name,sex,age,height,weight,avg(age) as avg_age
		from sashelp.class 
			group by sex;
quit;

data test;
	do until(last.sex);
		set sashelp.class;
		by sex notsorted;
	end;

	/**** some code to get avergae age ****/

	do until(last.sex);
		set sashelp.class;
		by sex notsorted;
		output;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2016 16:29:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DOW-LOOP-to-merge-summary-statistics/m-p/254481#M48542</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-03-04T16:29:47Z</dc:date>
    </item>
    <item>
      <title>Re: DOW LOOP to merge summary statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DOW-LOOP-to-merge-summary-statistics/m-p/254491#M48546</link>
      <description>&lt;P&gt;A couple of tricky points along the way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data test;&lt;BR /&gt;        numerator=0;&lt;BR /&gt;        denominator=0;
	do until(last.sex);
		set sashelp.class;
		by sex notsorted;&lt;BR /&gt;                if age &amp;gt; .Z then do;&lt;BR /&gt;                   numerator + age;&lt;BR /&gt;                   denominator + 1;&lt;BR /&gt;                end;
	end;
        if denominator then av_age = numerator / denominator;
	/**** some code to get avergae age ****/

	do until(last.sex);
		set sashelp.class;
		by sex notsorted;
		output;
	end;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Calculations of average age need to exclude missing values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course, DOW isn't the recommended approach for this problem. &amp;nbsp;But that's how to do it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In some circumstances (not here), you would have to pay attention to the possibility of an AGE value that exists in one loop but not the other.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2016 15:44:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DOW-LOOP-to-merge-summary-statistics/m-p/254491#M48546</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-03-04T15:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: DOW LOOP to merge summary statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DOW-LOOP-to-merge-summary-statistics/m-p/254501#M48551</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;. &amp;nbsp;Thank you. I was just experimenting how does double DOW LOOP works. What are the circumstances that it is best suited to?&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2016 16:02:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DOW-LOOP-to-merge-summary-statistics/m-p/254501#M48551</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-03-04T16:02:37Z</dc:date>
    </item>
    <item>
      <title>Re: DOW LOOP to merge summary statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DOW-LOOP-to-merge-summary-statistics/m-p/254513#M48553</link>
      <description>&lt;P&gt;Looks like this works as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
	do until(last.sex);
		set sashelp.class;
		by sex notsorted;
		count = sum (count, 1);
		sum_age = sum (sum_age, age);
	end;

	avg_age=sum_age/count;

	do until(last.sex);
		set sashelp.class;
		by sex notsorted;
		output;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Mar 2016 16:24:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DOW-LOOP-to-merge-summary-statistics/m-p/254513#M48553</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-03-04T16:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: DOW LOOP to merge summary statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DOW-LOOP-to-merge-summary-statistics/m-p/254518#M48554</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/64404"&gt;@SAS_inquisitive﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can find examples and explanations in various papers:&lt;/P&gt;
&lt;P&gt;"&lt;A href="http://www2.sas.com/proceedings/sugi28/099-28.pdf" target="_blank" rel="nofollow"&gt;The DOW (not that DOW!!!) and the LOCF in Clinical Trials&lt;/A&gt;" explains the basics. Further examples from the pharmaceutical area can be found in "&lt;A href="http://www.lexjansen.com/phuse/2009/tu/tu01.pdf" target="_blank" rel="nofollow"&gt;Practical Uses of the DOW Loop in Pharmaceutical Programming&lt;/A&gt;." Technically more advanced is "&lt;A href="http://support.sas.com/resources/papers/proceedings09/038-2009.pdf" target="_blank" rel="nofollow"&gt;The DOW-Loop Unrolled&lt;/A&gt;."&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2016 16:31:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DOW-LOOP-to-merge-summary-statistics/m-p/254518#M48554</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-03-04T16:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: DOW LOOP to merge summary statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DOW-LOOP-to-merge-summary-statistics/m-p/254523#M48556</link>
      <description>@ FreelanceReinhard. Thank you for these references.</description>
      <pubDate>Fri, 04 Mar 2016 16:36:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DOW-LOOP-to-merge-summary-statistics/m-p/254523#M48556</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-03-04T16:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: DOW LOOP to merge summary statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DOW-LOOP-to-merge-summary-statistics/m-p/254550#M48566</link>
      <description>&lt;P&gt;This works as long as you have no missing values for AGE. &amp;nbsp;If there are missing values, COUNT will be wrong.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2016 17:56:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DOW-LOOP-to-merge-summary-statistics/m-p/254550#M48566</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-03-04T17:56:35Z</dc:date>
    </item>
  </channel>
</rss>

