BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Linlin
Lapis Lazuli | Level 10

Hi Macro Experts,

I just found out that the . is not necessary in format date9.

%let startdate = "30apr2012"d;

%let myfriday="%sysfunc(intnx(week.6,&startdate,0,b),date9)"d;

%put myfriday: &myfriday;

Is this true in all sas versions or just in newer version?

Thanks - Linlin

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Linlin,  I think the correct answer is probably when did SAS start working correctly when inserting a format with an ending period into a macro statement?

Take a look at: http://groups.google.com/group/comp.soft-sys.sas/browse_thread/thread/cb3007714d347151

View solution in original post

4 REPLIES 4
art297
Opal | Level 21

Linlin,  I think the correct answer is probably when did SAS start working correctly when inserting a format with an ending period into a macro statement?

Take a look at: http://groups.google.com/group/comp.soft-sys.sas/browse_thread/thread/cb3007714d347151

Linlin
Lapis Lazuli | Level 10

Thank you Art!  - Linlin

Peter_C
Rhodochrosite | Level 12

thank you Art,

for referring to an old posting of mine (it must be about 10 years old! your memory is good!)

the issue hasn't changed - people (mostly those who call themselves sas programmers) see a trailing dot and imagine "format".

In fact that dot is only needed when a format is used on a put statement (likewise for informat on input statement) - to allow the compiler to recognise that you are not referring to another variable.

Deeply embedded in the data step compiler, the PUT() function expects a dot in a format name, also.

However PUTN (and informats in inputn) function has no need of the dot, as only a format name (in a variable value) can appear in the second parameter of the function. Having third and 4th parameters for "total formatted width" and "number of decimal places", it is the tolerance and generous flexibility of the SAS lanugage compilers that accept the dot, width and num-dec-pl. in the value of the format parameter.

So it is not a defect of the macro environment that %sysfunc( {function}, {format} ) allows you to place DATE9 in that {format} position, but generous flexibility.

(I believe PUTN() was introduced with SAS/AF-SCL and is not PUT(), because they couldn't extract the underlying compiler code that implements PUT() in a practical way because of the way that code is implemented)

peterC

Linlin
Lapis Lazuli | Level 10

Hi Art and Peter,

I wish I had known you long time ago. Thank you very much for the detailed information. - Linlin

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
  • 4 replies
  • 932 views
  • 3 likes
  • 3 in conversation