BookmarkSubscribeRSS Feed
ThomasH
Calcite | Level 5
Hi everybody,

I guess this is a very easy one, but I just cant figure it out on this friday afternoon...

I am passing a date9 value to another job in a loop, so it gets there as a macro variable.

So I have a variable &date, which resolves to 17998.

How do I convert it back to a DATE9. value? What's the name of the format of "17998".

data _null;
format x DATE9.;
x = input(resolve('&date'),DATE9.);
...

does not work.

Thanks a lot!

Thomas
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Use the SAS PUT function in an assignment statement with the desired format, such as DATE9. for your macro variable, either in a DATA step CALL SYMPUT or in a %LET statement using %SYSFUNC.

The SAS support http://support.sas.com/ website has a wealth of documentation and supplemental technical content - here is a Google advanced search argument which yielded several useful matches on this topic:

put macro variable date display site:sas.com

Scott Barry
SBBWorks, Inc.
DanielSantos
Barite | Level 11
If &DATE resolves to 17998, there's no conversion needed, just the appropriate format.

Just X=&DATE will do the job.

Actualy DATE9. is a numeric format.

17998 and '11APR2009'd are the same.

To see X as DATE9, just apply the format DATE9. to the X, or use formatted print (put X date9.;)

For example:

data _null_;
X=17998;
put X date9.;
run;

and you will see the NUMERIC value 17998 formated with the NUMERIC format date9.

Hope it helps.

ps: btw the call resolve("&DATE") is useless "&DATE" just will do.

Greetings from Portugal.

Daniel Santos at www.cgd.pt

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
  • 2 replies
  • 676 views
  • 0 likes
  • 3 in conversation