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 (May 2001, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 27 May 2001 11:26:55 -0400
Reply-To:     Jay Weedon <jweedon@EARTHLINK.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jay Weedon <jweedon@EARTHLINK.NET>
Organization: http://extra.newsguy.com
Subject:      Re: %do loop
Content-Type: text/plain; charset=us-ascii

%do loops require integer values, so there's an implicit conversion here. To fix, precede the &i with a 0, as in %put 0&i;

It gets trickier when &i is sometimes below 999, sometimes above 999, but you want 4 digits anyway. The leading zero then needs to be conditional, as in %if &i>999 %then %put &i; %else %put 0&i;

JW

On 26 May 01 13:57:46 GMT, Brad.Goldman@AUTOTRADER.COM (Goldman, Brad AT-Atlanta) wrote:

>I have the following %do loop in my code (greatly simplified to illustrate) >--------------------- >data _null_; >call symput('yesterday',substr(put(today()-1,yymmdd6.),3,4)); >call symput('dayone',substr(put(intnx('month',today()-1,0),yymmdd6.),3,4)); >run; > >%put _user_; >%do i = &dayone %to &yesterday; >%put &i; >%end; >----------------------- >Which generates the following output: >GLOBAL DAYONE 0501 >GLOBAL YESTERDAY 0525 >501 >502 >... >524 >525 >-------------------------- >My question/problem is this: What happened to the leading zero that >&yesterday and &dayone had, and how can I keep these zeros in front of the >date when it goes through the loop? I need to append a bunch of datasets >together of the form wc.wc<mmdd> for the current month. > >Any help appreciated! >Thank you, >Brad Goldman


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