<?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: DOW Loop Question in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/DOW-Loop-Question/m-p/147215#M2437</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I didn't write the code, i copied it directly from a paper.&amp;nbsp; Ultimately I am trying to figure out if a DOW loop can&amp;nbsp; be used to merge two data sets and what the code would look like.&amp;nbsp; I have read a few papers on the DOW loop but merging two data sets is not explicitly mentioned.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Sep 2014 19:52:40 GMT</pubDate>
    <dc:creator>BMI0776</dc:creator>
    <dc:date>2014-09-16T19:52:40Z</dc:date>
    <item>
      <title>DOW Loop Question</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/DOW-Loop-Question/m-p/147213#M2435</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm doing a bit of research on different methods to match/merge data in SAS.&amp;nbsp; I came across the following example in a paper.&amp;nbsp; Is this a DOW loop?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA alldata0;&lt;/P&gt;&lt;P&gt;SET ae;&lt;/P&gt;&lt;P&gt;DROP _: match; * Drop temporary variables;&lt;/P&gt;&lt;P&gt;match=0;&lt;/P&gt;&lt;P&gt;DO i=1 TO xnobs;&lt;/P&gt;&lt;P&gt;SET patdata (rename=(subject=_subject)) NOBS=xnobs POINT=i;&lt;/P&gt;&lt;P&gt;IF subject=_subject THEN DO;&lt;/P&gt;&lt;P&gt;match=1; OUTPUT; END;&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;IF match=0 THEN DO; * Output AE record if no match in CM;&lt;/P&gt;&lt;P&gt;CALL MISSING(trt_code); OUTPUT; END;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Sep 2014 18:54:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/DOW-Loop-Question/m-p/147213#M2435</guid>
      <dc:creator>BMI0776</dc:creator>
      <dc:date>2014-09-16T18:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: DOW Loop Question</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/DOW-Loop-Question/m-p/147214#M2436</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;almost your do loop has a problem as the xnobs may not yet be known at that moment ( set is not executed yet).&lt;/P&gt;&lt;P&gt;Could be solved by a getvarn or a while construct.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Sep 2014 19:47:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/DOW-Loop-Question/m-p/147214#M2436</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-09-16T19:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: DOW Loop Question</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/DOW-Loop-Question/m-p/147215#M2437</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I didn't write the code, i copied it directly from a paper.&amp;nbsp; Ultimately I am trying to figure out if a DOW loop can&amp;nbsp; be used to merge two data sets and what the code would look like.&amp;nbsp; I have read a few papers on the DOW loop but merging two data sets is not explicitly mentioned.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Sep 2014 19:52:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/DOW-Loop-Question/m-p/147215#M2437</guid>
      <dc:creator>BMI0776</dc:creator>
      <dc:date>2014-09-16T19:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: DOW Loop Question</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/DOW-Loop-Question/m-p/147216#M2438</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;xnobs is populated with the number of observations at data step compile time. So it is already known at the very beginning of the execution phase of the data step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No, it is not a DOW loop. It is rather a set/set point= combination, which accomplishes a many-to-many join.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;In a DOW loop you should see something &lt;STRONG&gt;similar&lt;/STRONG&gt; to this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;do until(condition);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set dataset;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5em; font-size: 10pt;"&gt;DOW loop itself is not a technique for joining or merging. It is rather reading and &lt;/SPAN&gt;analyzing&lt;SPAN style="line-height: 1.5em; font-size: 10pt;"&gt; data in blocks (the block is sometimes the whole dataset). It can be slightly faster then the standard data step, because it skips a couple of "maintenance tasks" that data step is doing by default at the beginning of each loop (setting variables to missing).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5em; font-size: 10pt;"&gt;But you can put a merge statement inside the loop if you want. Then it merges datasets.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Sep 2014 20:10:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/DOW-Loop-Question/m-p/147216#M2438</guid>
      <dc:creator>gergely_batho</dc:creator>
      <dc:date>2014-09-16T20:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: DOW Loop Question</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/DOW-Loop-Question/m-p/147217#M2439</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are examining merging techniques it may be time to look into Proc SQL and various types of joins as they may be easier to understand and maintain.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Sep 2014 20:18:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/DOW-Loop-Question/m-p/147217#M2439</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-09-16T20:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: DOW Loop Question</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/DOW-Loop-Question/m-p/147218#M2440</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is it a DOW loop?&amp;nbsp; Not in my opinion.&amp;nbsp; DOW loops should not be using point= (but you may encounter other opinions about that).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it good code?&amp;nbsp; Definitely not.&amp;nbsp; It may work (xnobs will not be a problem, since nobs= variables are populated during the compilation phase of the DATA step), but it will run through 100% of the observations in PATDATA for each observation in AE.&amp;nbsp; Moreover, it loses some functionality because it cannot detect when PATDATA contains multiple observations for the same SUBJECT.&amp;nbsp; A MERGE would automatically print a note in the log if both data sets contained multiple observations for a SUBJECT:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data alldata0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; merge ae (in=in1) patdata (in=in2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by subject;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if in1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; treat = in2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My interpretation:&amp;nbsp; the author was either playing around or was shooting for job security.&amp;nbsp; Or maybe wanted to achieve a many-to-many match but didn't know SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Depending on what you are trying to document,&amp;nbsp; you may be interested in searching for look-up techniques.&amp;nbsp; That would include formats and hash tables, not just merge.&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>Tue, 16 Sep 2014 20:20:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/DOW-Loop-Question/m-p/147218#M2440</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-09-16T20:20:28Z</dc:date>
    </item>
    <item>
      <title>Re: DOW Loop Question</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/DOW-Loop-Question/m-p/147219#M2441</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I already looked into Format and Hash tables and I am very familiar with SQL.&amp;nbsp; I'm just exploring different techniques for my general knowledge.&amp;nbsp; Thanks for the input&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Sep 2014 20:23:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/DOW-Loop-Question/m-p/147219#M2441</guid>
      <dc:creator>BMI0776</dc:creator>
      <dc:date>2014-09-16T20:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: DOW Loop Question</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/DOW-Loop-Question/m-p/147220#M2442</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;for merging joining there are some older principles as "balance line" they can be nicely programmed using this kind of technique.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can solve some problems with this that are not easily possible in a other way.&lt;/P&gt;&lt;P&gt;Recently there was some question on getting a record back/forward within the same dataset with a timed value condition.&lt;/P&gt;&lt;P&gt;The number of records that could be there are unknown, it just a condition to find&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;I came up with this one a merge on the own dataset moving the readpointer up/backward :&lt;/P&gt;&lt;P&gt;&amp;nbsp; data fixings300;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set fixings nobs=fn_nobs ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Retain eventlk 1&amp;nbsp; ; check=1 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do while (eventlk &amp;lt; fn_nobs &amp;amp; check ) ; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set fixings (rename=(bidprc=bidprc5 offerprc=offerprc5m eventid=event5m dtcur=dtcur5m) ) point=eventlk&amp;nbsp; end=end5m ; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( dtcur+300 &amp;gt; dtcur5m ) then eventlk=eventlk+1 ; else check=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another more a merge. but same kind of question. Just a condition to find not knowing any fixed merged value.&amp;nbsp; &lt;/P&gt;&lt;P&gt;I had the problem of the value not being defined here when validating the code. Getting back tot the attrn function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let dsid = %sysfunc(open(prices));&lt;/P&gt;&lt;P&gt;%let pr_nobs =%sysfunc(attrn(&amp;amp;dsid,NOBS));&lt;/P&gt;&lt;P&gt;%let rc = %sysfunc(close(&amp;amp;dsid));&lt;/P&gt;&lt;P&gt;%put prices has &amp;amp;pr_nobs observations;&amp;nbsp; &lt;/P&gt;&lt;P&gt;/* using assumption oredered events - prices */&lt;/P&gt;&lt;P&gt;data results;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set Events nobs=evn_nobs ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Retain eventlk 1&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; check=1 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do while (eventlk &amp;lt; &amp;amp;pr_nobs &amp;amp; check ) ; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set Prices (rename=(Ticker=pTicker TradeDate=PriceDate TradeTime=Pricetime ) ) point=eventlk&amp;nbsp; end=endprc ; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if ( Ticker &amp;gt; PTicker | ( Ticker = PTicker &amp;amp; TradeDate &amp;gt; PriceDate) |( Ticker = PTicker &amp;amp; TradeDate = PriceDate &amp;amp; TradeTime &amp;gt; Pricetime ) ) then eventlk=eventlk+1 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else check=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if not endprc then eventlk=eventlk-1 ; /* one back that has passed set equation */&lt;/P&gt;&lt;P&gt;&amp;nbsp; set Prices (rename=(Ticker=pTicker TradeDate=PriceDate TradeTime=Pricetime ) ) point=eventlk&amp;nbsp; end=endprc ; &lt;/P&gt;&lt;P&gt;&amp;nbsp; IF ( Ticker=PTicker &amp;amp; TradeDate = PriceDate) then output; /* */&lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;P&gt;proc print;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Sep 2014 20:23:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/DOW-Loop-Question/m-p/147220#M2442</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-09-16T20:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: DOW Loop Question</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/DOW-Loop-Question/m-p/147221#M2443</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK.&amp;nbsp; For general knowledge, here's an example of a DOW loop that use AE data.&amp;nbsp; The intent is to output all AEs for a subject that had at least one "Serious" AE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do until (last.subject);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by subject;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if severity='Serious' then flag=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do until (last.subject);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by subject;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if flag=1 then output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first loop determines whether the subject had a serious AE.&amp;nbsp; Then the second loop reads the same records and outputs if needed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Sep 2014 20:31:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/DOW-Loop-Question/m-p/147221#M2443</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-09-16T20:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: DOW Loop Question</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/DOW-Loop-Question/m-p/147222#M2444</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings09/038-2009.pdf" title="http://support.sas.com/resources/papers/proceedings09/038-2009.pdf"&gt;http://support.sas.com/resources/papers/proceedings09/038-2009.pdf&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2014 07:07:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/DOW-Loop-Question/m-p/147222#M2444</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-09-17T07:07:43Z</dc:date>
    </item>
  </channel>
</rss>

