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

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

1 ACCEPTED SOLUTION

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

%put &date.;

View solution in original post

3 REPLIES 3
gamotte
Rhodochrosite | Level 12

Hello,

 

data _NULL_;
    dt=input("&date.",yymmdd10.);
    call symput("date",put(dt,date9.));
run;
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

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

%put &date.;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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