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 (October 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 6 Oct 2009 13:16:21 -0700
Reply-To:     "Schwarz, Barry A" <barry.a.schwarz@BOEING.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Schwarz, Barry A" <barry.a.schwarz@BOEING.COM>
Subject:      Re: How to Macroise??
In-Reply-To:  <840f6c2c-cd7e-40a7-880c-e9a06b58d234@13g2000prl.googlegroups.com>
Content-Type: text/plain; charset="us-ascii"

No macro needed. If you really must process character variables rather than date variables:

Given your control parameter in the form 'yyyymm', use the SUBSTR and MDY functions to create the SAS date for the first of the month.

Use a DO loop and the INTNX function to build an array of 12 dates for the 12 months starting with the date created above.

Use a DO loop and the PUT, MONTH, and YEAR functions to build two character arrays for the month and year corresponding to each of the 12 dates.

Loop through your input

Use a DO loop to find the first element in the pair of arrays which match the two variables in your data set.

IF a match was found, Set your delq...algn variable to the value in delq...12 Use the SUBSTR function to replace the appropriate portion with the contents of dummy_string ELSE Set your old...ago variable to 1

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Get Sent: Tuesday, October 06, 2009 4:21 AM To: SAS-L@LISTSERV.UGA.EDU Subject: How to Macroise??

Hi,

I've the following static code as given below.

###################################################### dummy_string = '************';

if rec_mnth = '01' and rec_year = '2008' then delq_str12_algn = delq_str_12; else if rec_mnth = '12' and rec_year = '2007' then delq_str12_algn = substr(delq_str_12,1,11)||substr(dummy_string,1,1); else if rec_mnth = '11' and rec_year = '2007' then delq_str12_algn = substr(delq_str_12,1,10)||substr(dummy_string,1,2); else if rec_mnth = '10' and rec_year = '2007' then delq_str12_algn = substr(delq_str_12,1,9)||substr(dummy_string,1,3); else if rec_mnth = '09' and rec_year = '2007' then delq_str12_algn = substr(delq_str_12,1,8)||substr(dummy_string,1,4); else if rec_mnth = '08' and rec_year = '2007' then delq_str12_algn = substr(delq_str_12,1,7)||substr(dummy_string,1,5); else if rec_mnth = '07' and rec_year = '2007' then delq_str12_algn = substr(delq_str_12,1,6)||substr(dummy_string,1,6); else if rec_mnth = '06' and rec_year = '2007' then delq_str12_algn = substr(delq_str_12,1,5)||substr(dummy_string,1,7); else if rec_mnth = '05' and rec_year = '2007' then delq_str12_algn = substr(delq_str_12,1,4)||substr(dummy_string,1,8); else if rec_mnth = '04' and rec_year = '2007' then delq_str12_algn = substr(delq_str_12,1,3)||substr(dummy_string,1,9); else if rec_mnth = '03' and rec_year = '2007' then delq_str12_algn = substr(delq_str_12,1,2)||substr(dummy_string,1,10); else if rec_mnth = '02' and rec_year = '2007' then delq_str12_algn = substr(delq_str_12,1,1)||substr(dummy_string,1,11); else old_12m_ago = 1;

##########################

Delq_str_12 is a string of 12 characters indicating customer delinquency(any value between 0-5).The above code was written for the period starting January 2008 and going back 12 months. If i need to pass the month and year in a macro, how to make the above snippet dynamic in a macro(by passing value 200801)?

Thanks Easwara


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