Date: Fri, 19 Jan 2007 16:03:16 +0000
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ian Whitlock <iw1junk@COMCAST.NET>
Subject: Re: Data Step Loop within merge
Summary: MERGE is the wrong tool.
Here is one approach.
/* create test data set of holidays */
data holidays ;
input h date9. ;
/* turn holiday information into a format */
data fmtdata ;
retain fmtname "holidays" ;
set holidays ( rename = ( h=start) ) end = eof ;
label = "1" ;
if eof then
hlo = "O" ;
label = "0" ;
proc format cntlin = fmtdata ;
/* create test data */
data w ;
do old_date = "20dec2006"d to "5jan2007"d ;
/* add new date */
data q ;
format old_date new_date weekdate. ;
set w ;
new_date = old_date + 2 ;
do while ( put(new_date,holidays.) = "1" or
weekday(new_date) in ( 1, 7)) ;
new_date + 1 ;
If a print of Q does not show what you expect than explain why
and restate what you which to accomplish.
Date: Thu, 18 Jan 2007 21:54:09 -0800
Reply-To: joshn <joshis@GMAIL.COM>
Sender: "SAS(r) Discussion"
From: joshn <joshis@GMAIL.COM>
Subject: Data Step Loop within merge
Comments: To: sas-l
Content-Type: text/plain; charset="iso-8859-1"
I am trying to calculate at least 2 days after a target day that
a weekend day or a public Holiday.
I have a list of Public holidays and Weekends in a separate data
I'm trying to merge these, compare the calculation of the target
2 to the public holiday list, and if there is a match itterate
calculation and loop.
merge old_date pub_holidays;
new_date = date + 2;
do until (new_date ne pub_date);
new_date + 1;
I know there is something wrong here, because it's just running
running and I'm not getting any results. Whats the anwser?