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 (August 1999, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 19 Aug 1999 21:17:45 +0100
Reply-To:     peter.crawford@DB.COM
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Peter Crawford <peter.crawford@DB.COM>
Subject:      SAS MACRO SAS date question formatting title dates
Comments: To: rjf2@cdc.gov
Content-type: text/plain; charset=us-ascii

take a macro like %now(f=datetime); %sysfunc( datetime(),&f) %mend now;

take your start and end values like %LET BEGDATE=01jan1999; *BEGINNING DATE; %LET ENDDATE=30jun1999; *ENDING DATE;

Prepare your proc print title like

title "from %sysfunc( putn( "&begdate"D, date9))" " to %sysfunc( putn( "&enddate"D, date9))";

and a footnote demonstrating current time.......

footnote "repoorting @ %now" ;

At the time these title and footnote statements are interpreted by the SAS compilers, the % processes will be evaluated.

Those date9 formats may be replaced with the date format of your choice

The code =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- %macro now(f=datetime); %sysfunc( datetime(),&f) %mend now;

%LET BEGDATE=01jan1999; *BEGINNING DATE; %LET ENDDATE=30jun1999; *ENDING DATE;

title "from %sysfunc( putn( "&begdate"D, date9))" " to %sysfunc( putn( "&enddate"D, date9))";

footnote "reporting @ %now" ;

option ps=25 ls=69; proc print data=sashelp.vmacro(obs=2); var name value; run; =----=----=-----=------=----=----=-----=------=----=----=-----=------ produced the result ===================================================================== from 01JAN1999 to 30JUN1999 19:11 Thursday, August 19, 1999 1

OBS NAME VALUE

1 _NQSEEN 1 2 CONFIG C:\SAS\CONFIG.SAS

=== lines deleted

reporting @ 19AUG99:21:11:59 =====================================================================

Datum: 19.08.99 20:56 An: SAS-L@listserv.uga.edu

Antwort an: rjf2@cdc.gov

Betreff: Re: SAS MACRO SAS date question Nachrichtentext:

From: Stephen Arthur [mailto:sarthur67@YAHOO.COM] /I set up code to create a SAS date constant like this: /%LET BEGDATE='01jan1999'd; *BEGINNING DATE; /%LET ENDDATE='30jun1999'd; *ENDING DATE; /Do I need the quotes around the date?

depends on how -- and where -- you want to use it

/In this case, the date prints as '01jan1999'd in a PROC PRINT title /statement. I don't think this is correct.

Know Where You're at else No Where: You're at!

are you in a data step? No. your macro variables can be used in a data step but as you already know you get the exact string in the TITLE statement.

20 %LET BEGDATE='01jan1999'd; 21 data _null_; 22 file log; 23 date = &BEGDATE;PUT DATE=;PUT DATE= date9.; 24 stop; 25 run;

date=14245 date=01JAN1999

if you will clearly state your task we'll be able to help you.

something like: "I want to put the begin- and end-date of a report in the title(s)."

Ron Fehd the task maven CDC Atlanta GA


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