SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Formatting &sysdate in a precode %let statement

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 90
Accepted Solution

Formatting &sysdate in a precode %let statement

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.


Accepted Solutions
Solution
‎09-11-2012 08:24 AM
Super Contributor
Posts: 349

Re: Formatting &sysdate in a precode %let statement

Posted in reply to EinarRoed

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


All Replies
Super Contributor
Posts: 349

Re: Formatting &sysdate in a precode %let statement

Posted in reply to EinarRoed

Hi,

Try this..

data _null_;

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

   run;

%let reportname = warning01_&date;

%put &reportname;

Thanks,

Shiva

Frequent Contributor
Posts: 90

Re: Formatting &sysdate in a precode %let statement

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

Respected Advisor
Posts: 4,173

Re: Formatting &sysdate in a precode %let statement

Posted in reply to EinarRoed

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

Solution
‎09-11-2012 08:24 AM
Super Contributor
Posts: 349

Re: Formatting &sysdate in a precode %let statement

Posted in reply to EinarRoed

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

Respected Advisor
Posts: 3,799

Re: Formatting &sysdate in a precode %let statement

Posted in reply to EinarRoed

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

Respected Advisor
Posts: 4,173

Re: Formatting &sysdate in a precode %let statement

Posted in reply to EinarRoed

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.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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