date question

  • Follow


Can someone tell me why I am getting different results for date1 and date2?

data _null_;
    date1 = '31MAR2003'd;
    call symput ('date1',date1);
run;
%let date2 =%STR('31MAR2003'd);
%put &date1 ;
%put &date2 ;

1208  %let date2 =%STR('31MAR2003'd);
1209  %put &date1 ;
15795
1210  %put &date2 ;
'31MAR2003'd
0
Reply cynqiu (10) 10/3/2003 4:46:30 PM

The date was being resolved in the datastep.  Try this:

data _null_;
    date1 = "'31MAR2003'd";
    call symput ('date1',date1);
run;
%let date2 =%STR('31MAR2003'd);
%put &date1 ;
%put &date2 ;


Paul Choate
DDS Data Extraction
(916) 654-2160

-----Original Message-----
From: Cynthia qiu [mailto:cynqiu@YAHOO.COM]
Sent: Friday, October 03, 2003 9:47 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: date question

Can someone tell me why I am getting different results for date1 and date2?

data _null_;
    date1 = '31MAR2003'd;
    call symput ('date1',date1);
run;
%let date2 =%STR('31MAR2003'd);
%put &date1 ;
%put &date2 ;

1208  %let date2 =%STR('31MAR2003'd);
1209  %put &date1 ;
15795
1210  %put &date2 ;
'31MAR2003'd
0
Reply pchoate (2551) 10/3/2003 5:06:11 PM


On 3 Oct 03 16:46:30 GMT, cynqiu@YAHOO.COM (Cynthia qiu) wrote:

>Can someone tell me why I am getting different results for date1 and date2?
>
>data _null_;
>    date1 = '31MAR2003'd;
>    call symput ('date1',date1);
>run;
>%let date2 =%STR('31MAR2003'd);
>%put &date1 ;
>%put &date2 ;
>
>1208  %let date2 =%STR('31MAR2003'd);
>1209  %put &date1 ;
>15795
>1210  %put &date2 ;
>'31MAR2003'd

Dates are stored by SAS as integers. The expression '31mar2003'd in a
data step generates an integer that corresponds to the number of days
between 01jan1960 and 31mar2003. Your call symput statement converts
this integer to a string, and stores it as a macro variable. When you
define date2 you are simply writing the string <'31mar2003'd> as a
macro variable - outside of the data step no integer conversion
occurs. 

JW
0
Reply jweedon (207) 10/3/2003 5:40:14 PM

2 Replies
36 Views

(page loaded in 0.32 seconds)

Similiar Articles:













7/22/2012 9:45:59 PM


Reply: