Date: Thu, 7 Jun 2001 09:34:59 -0400
Reply-To: Howard Schreier <howard_schreier@ITA.DOC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Howard Schreier <howard_schreier@ITA.DOC.GOV>
Subject: Re: Macro date question
There are a couple of issues here.
First, as Ron has already shown, CALL SYMPUT, rather than %LET, is the way
to create a macro variable during execution of a DATA step.
Second, SAS dates are numeric, whereas macrovariables are character. So it
can't be done.
But one can create a macrovariable containing the string value representing
a date constant. This can be used in a DATA step in any context where a
numeric expression is appropriate.
First create the pre-existing macrovariable containing a date in mm/dd/yy
Now convert it:
The expression used as the second argument to CALL SYMPUT first uses the
INPUT function to convert the value to a numeric SAS date, the uses the PUT
function to convert that back to a character value (07JUN2001), then wraps
that in quotes and appends the letter "d", which conforms to the notational
convention for a date constant. So the macrovariable START1 is created with
Now demonstrate use:
nextday = &START1 + 1;
put 'Next day is ' nextday weekdate.;
This just advances the date by one and prints it in the log. Result:
Next day is Friday, June 8, 2001
The log does *not* have a message about type conversion, because both
operands in the addition are numeric.
On Wed, 6 Jun 2001 22:27:47 -0400, Crystal Vierhout
>I have probably an easy question. If a date in coming in SAS/Intranet as
01/01/99 what is the easiest way to make it a macro variable SAS date?
Does anyone have a suggestion?
>length STRING1 $3. DUMMY $3. ;
>if start1 ne . then %LET START1=&START1;