%SYSFUNC(INTNX(...))

  • Permalink
  • submit to reddit
  • Email
  • Follow


Hi.
I'm trying to put the last day of July into a macro variable and I just
figured out how. The INTNX function behaves differently in the %SYSFUNC
macro function and in the DATA Step.

Examples:
%LET MinDato = %SYSFUNC( MDY(7,1,2005) );

When in the Data step the time interval must have quotes:
data _null_;
  call symput('MaxDato',intnx('month',&mindato,1)-1);
run;

But when using the %SYSFUNC macro function the interval must NOT have
quotes:
%LET MaxDato = %EVAL( %SYSFUNC( intnx(month,&mindato,1) ) -1 );

This applies to other functions with quoted arguments as well.

When using quotes in the %SYSFUNC version:
WARNING: An argument to the function INTNX referenced by the %SYSFUNC
or %QSYSFUNC macro function is out of range.

Not using quotes in the Data step version:
NOTE: Variable month is uninitialized.

Finally, I found it mentioned in the OnlineDoc:
Interfaces with the Macro Facility
Using SAS Language Functions in the DATA Step and Macro Facility
"Because %SYSFUNC is a macro function, you do not need to enclose
character values in quotation marks as you do in SAS language
functions."

Anyways, I believe the correct sentence should be "...you CANNOT
enclose character values in quotation marks...".

Similarly in the details for the %SYSFUNC() macro function:
"Because %SYSFUNC is a macro function, you do not need to enclose
character values in quotation marks as you do in DATA step functions."

Well well, not a big deal, but still confusing until you realize the
difference ;)

I guess that this is common knowledge to many of you, but after
spending some time figuring it out I though I'd document my findings.

Regards, Terje=)

0
Reply terje.kvambe (2) 9/7/2005 4:20:44 PM

See related articles to this posting


Terje,

Another thing to look at when applying formats when using sysfunc you
do not need the trailing dot like you do in a data step.

Toby Dunn

0
Reply tobydunn (6019) 9/7/2005 4:55:39 PM
comp.soft-sys.sas 130710 articles. 26 followers. Post

1 Replies
203 Views

Similar Articles

[PageSpeed] 16


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

SYSFUNC
I need to get rid of all registered entries of myFunc across libraries. So does: DROP FUNCTION myLib/myFunc = DELETE FROM SYSFUNCS where SPECIFIC_NAME = 'myFunc' ? Or does the DROP FUNCTION statement performed other housecleaning-wizardry? Thanks, Steve ...

%SYSFUNC ...
hello everybody, can someone help me to repair the following code : %LET MOIS2 = %SYSFUNC(INTNX('MONTH',%SYSFUNC(date()),-3)); %PUT &MOIS2; thank. ash. On May 5, 10:53=A0am, ash007 <RamsamyAsh...@gmail.com> wrote: > hello everybody, > > can someone help me to repair the following code : > > %LET MOIS2 =3D %SYSFUNC(INTNX('MONTH',%SYSFUNC(date()),-3)); > %PUT &MOIS2; > > thank. > > ash. 3 %LET MOIS2 =3D %SYSFUNC(INTNX(MONTH,%SYSFUNC(date()),-3),date9.); 4 %PUT &MOIS2; 01FEB2008 thank ! ...

%sysfunc
Hi All..here by i create one global macro for test...want i want to know = this globalmacro exist r not...so i am using the following programme. but it will show the following error....here i am having lot of = question.. 1.in my editior window the %sysfunc --indicate black color. 2.Here what u mean by i in the sysfunc (ie for format options in = sysfunc) and other than any format view available...pl tell NOTE: i am working in V8,windows thank you Boopathy /**********My programme*********************/ %let test=3D5; options spool; options symbolgen mlogic mprint; %macro macx(mar); %let = x=...

INTNX, INTCK
Recently there was a query re fiscal dates. The following excellent presentation from Jerry Le Breton of SAS Australia and New Zealand Users Group may have most or all of the answers. http://sausag.sasusers.net/Presentations.htm <http://sausag.sasusers.net/Presentations.htm> The date of the presentation was 20 May 2004 ********************************************************************* This message and any attachments are solely for the intended recipient. If you are not the intended recipient, disclosure, copying, use or distribution of the information included in this message is...

%SYSFUNC concept
Hi all.., i would like to know the whole function of %SYSFUNC with the all = options..in SAS v8 doc is not well...pl give the referring = doc/webid/communicate mailid... Thanks.. Boopathy.S(PATH) ...

%sysevalf and %sysfunc
%let number = 33.33; %let x2 = %sysevalf(%sysfunc(int(&number))); works while %let x2 = %sysfunc(int(%sysevalf(&number))); does not. with the error being that the argument supplied to INT is not a number. This seems rather odd as %sysevalf should be evaluating &number as a number. Could someone explain what's going on?? On Aug 19, 1:17=A0pm, dc353 <dc...@hotmail.com> wrote: > %let number =3D 33.33; > > %let x2 =3D =A0%sysevalf(%sysfunc(int(&number))); > > works while > > %let x2 =3D %sysfunc(int(%sysevalf(&number))); does not. =A0with ...

INTNX questoin
This is in the middle of a bunch of legacy code I inherited. I'm supposed to know what 'THISMON' returns. Once I get that figured out, I can reverse engineer what this bit is doing, otherwise, it is a big mystery as to why (it appears) someone would set the variable 'THISMON' -40. Or I might be wrong. DATA _NULL_; THISMON=INTNX('MONTH', '01APR2001'D, &I-40); CALL SYMPUT ('THISMON', THISMON); RUN; Are you able to please tell us where the value of &I comes from and what it's value is? The value of THISMON is the SAS...

Question on Intnx
Hello, How can I use intnx to generate a data that is 3 business days before a given date? For example, how can I get Feb 21, if a date of Feb 28 is provided? I looked at the function, but couldn't find where I can define that I need 3 business days before. Thanks. Jeri On Feb 19, 2:53 pm, jeri...@FREDDIEMAC.COM (Jeri Ji) wrote: > Hello, > > How can I use intnx to generate a data that is 3 business days before a > given date? For example, how can I get Feb 21, if a date of Feb 28 is > provided? > > I looked at the function, but couldn't find where I can define ...

%sysfunc question
BDate is numeric, but submitting the following: Data _null_; .. .. .. oba.title(text:"Birthday: " || "%sysfunc(putn( BDate, worddate.))"); .. .. .. run; Results in: ERROR: Argument 1 to function PUTN referenced by the %SYSFUNC or %QSYSFUNC macro function is not a number. ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC argument list. Execution of %SYSCALL statement or %SYSFUNC or %QSYSFUNC function reference is terminated. Why, how can I correct that. Thanks, Masoud ...

%sysfunc(varname())
Hi All, I was wondering if someone who has 9.0 and/or 9.1 could tell me if the below problem is fixed. When I run the below in 8.2, the varname() function does not seem to respect the keep statement that was applied when the dataset was opened. When I reported this to SAS, they said it was a bug (Randy Herbison was kind enough to point out that it works as I would expect in real SCL), and should be fixed for v9. Has it been fixed? data q; array x{5} (1 1 1 1 1); run; %let dsid=%sysfunc(open(q (keep=x2 x4))); *attrn() knows number of variables after keep; %put Number of Vars: %sysfunc(...

Re: %SYSFUNC ...
Hi. Try this out: %LET MOIS2 = %SYSFUNC(PUTN(%SYSFUNC(INTNX(MONTH,%SYSFUNC(DATE()),- 3)),DATE9.)); %PUT &MOIS2; HTH, Madhu ...

%SYSFUNC problem
I wrote some code that won't execute correctly, and it gives me a message about the dataset already being open. I tried adding a statement before %sysfunc(open) statement that was basically a %sysfunc(close), but that didn't work. Has anyone else experienced this? ...

Re: %sysfunc
Boopathy: Your macro is fine, it's how it's being invoked that's causing the trouble. Simply executing the macro as you are results in the generation of a 1 or a 0, but within no context. In terms of what the SAS compiler sees ( ie. after all the macro stuff has compiled / executed ) is: options spool; options symbolgen mlogic mprint; 1 If provide a context, for example if you coded %put %macx(test); it'll execute without an error. Presumably you want to do something with the results of %macx: %macro testit; %if %macx(test) %then %do; proc blah blah; ...

intnx problem
sorry , but i think i posted it without subject Hi, i am trying to find out the near solution of intnx problem. If in intnx we use month as argument then we always get the first date of next month. if i want exact date of next month i have to do some sp work. i am providing some code. can any one improve this. DATA A; INPUT ID AGE dat mmddyy8. ; day1=day(dat); year1=year(dat); mon=month(dat); next=mon+1; if mon=12 then do; next=1 ; year1=year1+1; end; newdate=mdy(next,day1,year1); format dat newdate date7.; drop mon day1 next year1; CARDS; 1 23 12/11/72 2 24 11/10/72 3 25 01/3/71 ; proc pri...

intnx function
Hi all, I'm doing a program to calculate the end date of a contract having a start date (data) and a period (prazo). data desenalm.new_taxas_swp (drop=type period); set desenalm.new_taxas_sw; informat data_aux datetime18.0; format data_aux date9.; informat end_date date9.; format end_date date9.; data_aux=datepart(data); type=substr(prazo,1,1); if type eq 'D' then type='day'; else if type eq 'M' then type='month'; else if type eq 'A' then type='year'; period=substr(prazo,2,2); end_date=put((intnx(type, input(data_aux,date9.), period, ...

Re: %SYSFUNC problem
Yep, I had that problem years ago. But I fixed it. Seriously, your description is totally vague. Show us the code, please. No one has ANY idea what you are talking about. Paul A. Thompson, Ph.D. Division of Biostatistics, Washington University School of Medicine 660 S. Euclid, St. Louis, MO 63110-1093 314-747-3793 paul@wubios.wustl.edu -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of shankera Sent: Thursday, July 03, 2008 5:01 PM To: SAS-L@LISTSERV.UGA.EDU Subject: %SYSFUNC problem I wrote some code that won't execute correctly, and it g...

%sysfunc with CATS function
The program below sets up a variable &hhmm with a value of '0905'. If I use the CATS function in the data step, it returns, as I expect, string=THE_TIME_IS_0905 but if I use the CATS function from the %SYSFUNC function, the result is different: string=THE_TIME_IS_905 .... with the leading '0' disappeared. How can that possibly happen? "Macro variables contain only character data", according to http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a002293823.htm So I don't understand how the leading '0' can have been removed, wh...

Re: %SYSFUNC ... #3
Gerhard , Its not so interesting when one considers that the macro facility uses a dot to end a macro variable name. So basically the macro processor eats the dot on the end of the format name. Its akin to the fact that you dont need quotes in the macro facility to deleneate what you want to be interpreted as text and what you want SAS to interprete as having some meaning. THe macro language and the Data Step/Procedure languages have different philisophical bases and syntax. Toby Dunn "Don't bail. The best gold is at the bottom of barrels of crap." Randy Pausch "Be p...

%SYSFUNC, TRANWRD, and quoting
Greetings, Perhaps this is consistent, but still gave me pause. When using the TRANWRD function within a %SYSFUNC call, the arguments do not need to be quoted: 466 %let f1 =fVIII_P04_p12_A39_F_H08_64.ab1; 467 %let f2 = %sysfunc( tranwrd( &f1. , _F_ , _R_ )); 468 469 %put &f1; fVIII_P04_p12_A39_F_H08_64.ab1 470 %put &f2; fVIII_P04_p12_A39_R_H08_64.ab1 471 472 473 data _null_ ; 474 f2 = tranwrd( "fVIII_P04_p12_A39_F_H08_64.ab1" , "_F_" , "_R_" ) ; 475 put f2 ; 476 run; fVIII_P04_p12_A39_R_H08_64.ab1 Is this the general convention fo...

Re: INTNX questoin
Hi Jumbo Shrimps Jr., Well certainly the intnx function will increment/decrement the unit of measure forward or backward. The clarification comes in on that it may or may not be decrementing -40 months. The real question is the macro variable I. The entire picture depends on what the macro variable I (as seen as &I) is for and what the value of &I might be. Once you backtrack through your code and determine what the macro variable I is being used for, and what the values will be, then you will most like find the reason for offsetting the value of &I-40 is really going to be. Tha...

Re: %sysfunc(varname())
Quentin McMullen <quentin_mcmullen@BROWN.EDU> asked: > I was wondering if someone who has 9.0 and/or 9.1 could tell me if the > below problem is fixed. When I run the below in 8.2, the varname() > function does not seem to respect the keep statement that was applied > when the dataset was opened. When I reported this to SAS, they said it > was a bug (Randy Herbison was kind enough to point out that it works as I > would expect in real SCL), and should be fixed for v9. Has it been fixed? Umm.. no. Note the header I include, so you can see I'm running SAS 9.0 The...

%SYSFUNC and PUT function
Hi. I wanted to create integer macro variables of equal length, using the Zw.d format, e.g., 0001, 0002, 0003,... I figured I would do something like: %let v = %sysfunc(put(&i.,Z4.)); To my shock and dismay, this didn't work. I got the following message: ERROR: The PUT function referenced in the %SYSFUNC or %QSYSFUNC macro function is not found. Well, I was able to use the following clunky work-around: %let l = %length(&i.); %if &l. < 4 %then %let v = %sysfunc(repeat(0,3 - &l.))&i.; %else %let v = &i.; But what gives with sysfunc and put? Bug or feature? ...

INTNX documentation
Hi there, I'm asking me since I was born... The documentation for the INTNX function says: *************************** Increments a date, time, or datetime value by a given interval or intervals, and returns a date, time, or datetime value *************************** Now I want to go back one month: last_month_dt = intnx("month",datetime(),-1); That is wrong, because the value - obviously a legal datetime-value - is "invalid for the INTNX function". Could someone show me, how one can tell that function, that actual a DATETIME and not a DATE value comes and is ex...

Re: INTNX question
Jumbo , It is &I not I, so &I is the value of the what ever loop from the %DO I=&FST. %TO &LST.; is on. %Do I = &FST %To &LST ; LIBNAME IN "D00BP.XXXXXXX.INSTATE.DATA.G%sysfunc( putn( &I , z4 ) )V00" DISP=SHR; %End ; Gets you the same result as your code. Since I dont know what is contained in the rest of your program its hard to say what went wrong. But lets assume that Fst is equal to 1 and Lst is equal to say 5 here is what the code you have provided assuming the do-loop gets ended puts out: 25 %macro MakeLibNames( Fst = , Lst = ) ; 26 27...