LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (January 2007, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 19 Jan 2007 16:03:16 +0000
Reply-To:     iw1junk@COMCAST.NET
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Ian Whitlock <iw1junk@COMCAST.NET>
Subject:      Re: Data Step Loop within merge
Comments: cc: joshn <joshis@GMAIL.COM>

Summary: MERGE is the wrong tool. #iw-value=1

Joshn,

Here is one approach.

/* create test data set of holidays */ data holidays ; input h date9. ; cards ; 25dec2006 1jan2007 ;

/* turn holiday information into a format */ data fmtdata ; retain fmtname "holidays" ; set holidays ( rename = ( h=start) ) end = eof ; label = "1" ; output ; if eof then do ; hlo = "O" ; label = "0" ; output ; end ; run ; proc format cntlin = fmtdata ; run ;

/* create test data */ data w ; do old_date = "20dec2006"d to "5jan2007"d ; output ; end ; run ;

/* 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 ; end ; run ;

If a print of Q does not show what you expect than explain why and restate what you which to accomplish.

Ian Whitlock =============== Date: Thu, 18 Jan 2007 21:54:09 -0800 Reply-To: joshn <joshis@GMAIL.COM> Sender: "SAS(r) Discussion" From: joshn <joshis@GMAIL.COM> Organization: http://groups.google.com Subject: Data Step Loop within merge Comments: To: sas-l Content-Type: text/plain; charset="iso-8859-1" Hi All, I am trying to calculate at least 2 days after a target day that is not a weekend day or a public Holiday. I have a list of Public holidays and Weekends in a separate data set, I'm trying to merge these, compare the calculation of the target date + 2 to the public holiday list, and if there is a match itterate the calculation and loop. data new_date; merge old_date pub_holidays; new_date = date + 2; do until (new_date ne pub_date); new_date + 1; end; run; I know there is something wrong here, because it's just running and running and I'm not getting any results. Whats the anwser? Thanks, Joshn


Back to: Top of message | Previous page | Main SAS-L page