BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
EinarRoed
Pyrite | Level 9

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.

1 ACCEPTED SOLUTION

Accepted Solutions
shivas
Pyrite | Level 9

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;

testtest@domain.com

;

run;

%put &name;

Thanks,

Shiva

View solution in original post

6 REPLIES 6
shivas
Pyrite | Level 9

Hi,

Try this..

data _null_;

      call symput("date",put("&sysdate"d,ddmmyy10.));

   run;

%let reportname = warning01_&date;

%put &reportname;

Thanks,

Shiva

EinarRoed
Pyrite | Level 9

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".

Patrick
Opal | Level 21

%let email_address=testtest@domain.com;
%let email_name=%scan(%bquote(&email_address),1,@);
%put email_name= &email_Name;

shivas
Pyrite | Level 9

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;

testtest@domain.com

;

run;

%put &name;

Thanks,

Shiva

data_null__
Jade | Level 19

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

Patrick
Opal | Level 21

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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to connect to databases in SAS Viya

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.

Discussion stats
  • 6 replies
  • 3905 views
  • 8 likes
  • 4 in conversation