DATA Step, Macro, Functions and more

Date Format

Accepted Solution Solved
Reply
New Contributor WPH
New Contributor
Posts: 4
Accepted Solution

Date Format

Halo all,

 

I am quite new in SAS and I need your help.

 

Is anybody know how to change these date into DATE9 format in macro variable.

 

%LET date = %scan("$Date: 2018/02/07 08:50:51 $",2,': ');

%put &date.;

 

Thank you for your help


Accepted Solutions
Solution
‎02-13-2018 05:11 AM
Super User
Posts: 10,610

Re: Date Format

%LET date = %sysfunc(inputn(%scan("$Date: 2018/02/07 08:50:51 $",2,%str( )),yymmdd10.),date9.);

%put &date.;

View solution in original post


All Replies
Super Contributor
Posts: 320

Re: Date Format

Hello,

 

data _NULL_;
    dt=input("&date.",yymmdd10.);
    call symput("date",put(dt,date9.));
run;
Super User
Super User
Posts: 9,194

Re: Date Format

Its not a good idea to put data into macro variables.  Macro is nothing more than a text find and replace system, which will make your code longer and harder to maintain if you do not use it for its purpose.  To do your request, you could have lots of messy macro code, or use Base SAS which is what should be used for data:

data _null_;
  call symput('date',put(input(scan('$Date: 2018/02/07 08:50:51 $',2,": "),yymmdd10.),date9.));
run;

%put &date.;

If your quite new to SAS then step 1 is learn Base SAS - which is the actually running language, then learn the additional text replacement service macro later.

Solution
‎02-13-2018 05:11 AM
Super User
Posts: 10,610

Re: Date Format

%LET date = %sysfunc(inputn(%scan("$Date: 2018/02/07 08:50:51 $",2,%str( )),yymmdd10.),date9.);

%put &date.;
☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 109 views
  • 0 likes
  • 4 in conversation