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 (July 1998, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 9 Jul 1998 08:49:32 -0500
Reply-To:     rchild@ABTI.COM
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Randy Childs <rchild@ABTI.COM>
Subject:      Re: Drop variables based on date
Comments: To: winnona@MY-DEJANEWS.COM
Content-Type: text/plain; charset=ISO-8859-1

Winnona, How about something like the code below? Hope this is helpful.

SAS-L, Something curious happened when I ran this macro. If I use the %scan function to get the macro variable FINDMNTH as part of the %if condition, it does not work for the months of April (apr) and March (mar). I moved the "calculation" of this macro variable to a %let statement and everything works fine. Any ideas as to why that happened?

Randy Childs Sr. Stat. Programmer Alpha-Beta Technology

%let CURMNTH = apr98; %let DROPMNTH =;

%macro REMMNTH;

%let MNTHNAME = %substr(&CURMNTH,1,3); %let YEARNUM = %substr(&CURMNTH,4,2);

%put month=&MNTHNAME year=&YEARNUM;

%let MONTHS = %str(dec nov oct sep aug jul jun may apr mar feb jan dec nov oct );

%do I = 1 %to 12; %let FINDMNTH = %scan(&MONTHS,&I,%str(, )); %if %str(&FINDMNTH) = %str(&MNTHNAME) %then %do; %if &I > 9 %then %do; %let OVRYEAR = %eval(&YEARNUM - 1); %end; %do J = %eval(&I+1) %to %eval(&I+3); %let MNTH&J = %scan(&MONTHS,&J,%str( )); %if &J >= 13 %then %let DROPMNTH = &DROPMNTH &&MNTH&J..&OVRYEAR; %else %let DROPMNTH = &DROPMNTH &&MNTH&J..&YEARNUM; %end; %end; %end;

%mend;

%REMMNTH;

%PUT &DROPMNTH;


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