f



Re: MACRO not working for "00" to "98" #4

George,

As Gerhard mentioned, you're conditional checks for &cy="00", "99", and
"98" are all false because the macro parameter values do not include
quotes.

Every check fails, meaning they fall into the %else %do block.  Here
there is an error with cystartdate.  I think it should be
01JAN20&prev_cy_calc, but you have 01JAN200&prev_cy_calc (an extra zero
in the year).  This is why you are getting values of 20098 and 20097.



Jack






Jack Clark
Senior Research Analyst
phone: 410-455-6256
fax: 410-455-6850
jclark@hilltop.umbc.edu

University of Maryland, Baltimore County
Sondheim Hall, 3rd Floor
1000 Hilltop Circle
Baltimore, MD 21250




Confidentiality Notice: This e-mail may contain information that is legally privileged and that is intended only for the use of the addressee(s) named above. If you are not the intended recipient, you are hereby notified that any disclosure, copying of this e-mail, distribution, or action taken in reliance on the contents of this e-mail and/or documents attributed to this e-mail is strictly prohibited. If you have received this information in error, please notify the sender immediately by phone and delete this entire e-mail. Thank you.-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
George Joseph
Sent: Tuesday, June 09, 2009 1:10 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: MACRO not working for "00" to "98"

This macro should auto generate the correct Calender Year (CY) start
date
and two other dates that go back to the latter half of the previous
year. It
is failing since %sysevalf comes back with -1 for "00" but apparently my
conditional logic is not working either. So its creating 20098 and 20097
which are both invalid dates.
______________________________________________________

%macro one(cy);
data _null_;

%let prev_cy_calc=%sysevalf(&cy-1);

%if &cy="99" or &cy="98"
%then %do;
%let prev_cy_calc=%sysevalf(&cy-1);
%let cystartdate=01JAN19&prev_cy_calc;**should be 97 for CY=98, 99 for
CY 00
and so on***;
%end;

%if &cy="00" %then %do;
%let cystartdate=01JAN1999;**Since 00-1 is -1 it has to be
hardcoded****;
%end;

%else %do;
%let cystartdate=01JAN200&prev_cy_calc;
%end;


 call
symputx('prev_cy_fromdate',put(intnx('months',"&cystartdate"d,-6,'B'),da
te9.));
 call
symputx('prev_cy_todate',put(intnx('months',"&cystartdate"d,-1,'E'),date
9.));

run;

%put;
%put *******************************************;
%put CY START DATE: &cystartdate ;
%put PREVIOUS CY #: &prev_cy_calc ;
%put PREVIOUS CY START DATE: &prev_cy_fromdate ;
%put PREVIOUS CY END DATE: &prev_cy_todate;
%put *******************************************;
%put;

%mend one;

options mprint mcompilenote=all symbolgen;
%one(08)
%one(07)
%one(06)
%one(05)
%one(04)
%one(03)
%one(02)
%one(01)
%one(00)
%one(99)
%one(98)
0
jclark3 (202)
6/9/2009 5:27:58 PM
comp.soft-sys.sas 142828 articles. 3 followers. Post Follow

0 Replies
459 Views

Similar Articles

[PageSpeed] 41

Reply: