Dear TEam,
I have a little difficulty in understanding this topic from the paper mentioned below.
http://analytics.ncsu.edu/sesug/2006/SC11_06.PDF
Question1:
Is it true that when we use functions in Macro there is no trailing period after the name of the format??(theory on page 3 of the above paper says there is no need!!!!)
"The other thing of significance is that the informat and
format used in the InputN and PutN can be any valid SAS informat or format and there is no trailing
decimal."
I get the answer anyways with or without using the dot after the format name!!!!
%let Date = %Sysfunc( InputN( 01JAN2006 , Date9. ) ) ;
%put &Date;
Regards
The period or dot used with a format name is a parsing character. It is needed so that the parser can detect a difference between a format name and a variable name. In the macro language this is not necessary as there are no data set variables, only macro language elements (that start with a macro language trigger - & and %), and non macro language elements, which don't start with a trigger. functions such as the INPUT function know that the second argument is a format, so in the macro language the period is not necessary. I suspect that we should be grateful that the periods don't cause problems.
Karun: You can find a nice discussion about whether periods should or shouldn't be used at:
With the functions you mentioned you can also specify the length and number of decimal places in two additional fields to the right of the two you already used. If you include those values they will override any values you may have used in specifying the informat to use.
The period or dot used with a format name is a parsing character. It is needed so that the parser can detect a difference between a format name and a variable name. In the macro language this is not necessary as there are no data set variables, only macro language elements (that start with a macro language trigger - & and %), and non macro language elements, which don't start with a trigger. functions such as the INPUT function know that the second argument is a format, so in the macro language the period is not necessary. I suspect that we should be grateful that the periods don't cause problems.
Thanks both of you for the response. Did u try it and see for yourself the above example i posted with a period and without after the Date
Regards
Karun, Of course I tried it (but not until after you asked if I had)!
Surprised that you weren't surprised that neither the value, nor the informat, could have quotes around them. The exact opposite is required in open code. e.g.:
data have;
input stuff $9.;
date=inputn(stuff,"date9.");
date2=InputN( "01JAN2006" , "Date9." );
cards;
10jan2012
1nov2012
;
%let Date = %Sysfunc( InputN( 01JAN2006 , Date,9 ) ) ;
%put &date.;
Hi,
I agree wid you altogether. I was reading about it too from the same paper I posted......
"Remember that the macro facility considers everything not
preceded by a % or & to be text, which is different from the data step where words have meaning and we
quote the words we want to be considered as text."
Regards
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.