How do I change the format of &sysdate inside a DI Studio precode? Here's what it currently looks like:
%let reportname = warning01_&sysdate;
I'd like it to be in the DDMMYY10. format.
Thanks.
Hi,
If you have more name then you need to combine with _N_ or use proc sql to create macro variables.
data _null_;
input name $ 40.;
name=scan(name,1,'@');
call symput('name',name);
cards;
;
run;
%put &name;
Thanks,
Shiva
Hi,
Try this..
data _null_;
call symput("date",put("&sysdate"d,ddmmyy10.));
run;
%let reportname = warning01_&date;
%put &reportname;
Thanks,
Shiva
Thanks Shivas & Patrick. I have a quick follow-up.
In DI Studio precode, how do I scan an email address and put everything that's in front of the @ into a macrovariable?
In example, if my email address is testtest@domain.com, I want the macrovariable to be set to "testtest".
%let email_address=testtest@domain.com;
%let email_name=%scan(%bquote(&email_address),1,@);
%put email_name= &email_Name;
Hi,
If you have more name then you need to combine with _N_ or use proc sql to create macro variables.
data _null_;
input name $ 40.;
name=scan(name,1,'@');
call symput('name',name);
cards;
;
run;
%put &name;
Thanks,
Shiva
Perhaps something like this.
5 %let reportname = warning01_%sysfunc(today(),DDMMYY10.);
6 %put NOTE: &reportname;
NOTE: warning01_11/09/2012
or this
7 %let reportname = warning01_%sysfunc(today(),DDMMYYd10.);
8 %put NOTE: &reportname;
NOTE: warning01_11-09-2012
Not sure if format ddmmyy10. is the best choice to be used as part of a report name (as it creates a date with slashes). But here you go:
%let reportname =warning01_%sysfunc(inputn(&sysdate,date9.),ddmmyy10.);
%put reportname= &reportname;
I'd probabely use format YYMMDDN8. instead.
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.