BookmarkSubscribeRSS Feed
Filipvdr
Pyrite | Level 9
%global datim = datetime();
%put &datim;
ods html file="/imec/other/imecweb/osp/fab300/test/shift_reports/PrioLotReport.html" (title="Prio Lot Report") stylesheet=(URL="http://imecwww.imec.be/~osp/fab300/test/ImecStyle.css");
ods listing close;
ods escapechar='^';
/* title */
ods html text='^S={just=c font_size=15pt foreground=black} Prio Lot Report - Last Run on &datim ^S={}';

but &datim shows as &datim, any solutions?
6 REPLIES 6
Tim_SAS
Barite | Level 11
Enclose the text in quotes instead of apostrophes. SAS does not resolve macro variables within apostrophes.
Andre
Obsidian | Level 7
Apparently more unclear Tim

[pre]
%global datim= %sysfunc(compress(%sysfunc(datetime(),IS8601DT.), -:));
%global dati = datetime();
%put &datim;%put &dati;
ods listing close;
ods html file="d:\temp\PrioLotReport.html" (title="Prio Lot Report") ;
ods escapechar='^';
/* title */
*ods html text="^S={just=c font_size=15pt foreground=black} Prio Lot Report - Last Run on &datim &dati ^S={}";
ods html text="Prior Lot Report - Last Run on %sysfunc(datetime()) &sysdate
&datim &dati ";
proc print data=sashelp.class(obs=1);run;
ods html close;


[/pre]

Is it more specifically a problem of how the ods clothing is working and
WHEN is it passing the chain to the ods construct ?

In my test the direct datetime and sysdate are resolved but not the macros variables

Andre
Tim_SAS
Barite | Level 11
The ODS statement is no different than any other statement. The macro processor runs before the ODS statement is executed. The ODS statement gets the text that the macro processor produced. I ran your test:

[pre]
%global datim;
%let datim = %sysfunc(compress(%sysfunc(datetime(),IS8601DT.), -:));
%global dati;
%let dati = datetime();
%put &datim;%put &dati;
ods listing close;
ods html file="PrioLotReport.html" (title="Prio Lot Report") ;
ods escapechar='^';
/* title */
*ods html text="^S={just=c font_size=15pt foreground=black} Prio Lot Report - Last Run on &datim &dati ^S={}";
ods html text="Prior Lot Report - Last Run on %sysfunc(datetime()) &sysdate &datim &dati ";
proc print data=sashelp.class(obs=1);run;
ods html close;
[/pre]

The text in the HTML file is:
Prior Lot Report - Last Run on 1614686110.021 02MAR11 20110302T115509 datetime()
Andre
Obsidian | Level 7
You are right, Tim
I think i was perhaps opening the wrong html file on my pc without reading carefully the log.
In fact rereading the code
i reproduce the problem i have encounter
when based too quickly upon the initial %global statement
i did not apply the correct syntax
%global datim; for defining the status of a macro variable
and then only after
%let datim=
with the definition of the content.
%global datim= genders errors in the log
Sorry
Andre Message was edited by: Andre
Filipvdr
Pyrite | Level 9
thanks, it is working
Peter_C
Rhodochrosite | Level 12
> %global datim = datetime();

is this expecting %global to assign a value?
sorry, it doesn't work that way.
the above syntax generates an ERROR: pointing to the '=' in my SAS9.2

you need %LET datim = something ;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1840 views
  • 0 likes
  • 4 in conversation