%SYSFUNC(INTNX(...))

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
9/7/2005 4:20:44 PM
comp.soft-sys.sas 133813 articles. 0 followers. Post Follow

1 Replies
530 Views

Similar Articles

[PageSpeed] 0
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
tobydunn (6018)
9/7/2005 4:55:39 PM
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 ...

Re: INTNX documentation
On Thu, Mar 5, 2009 at 7:46 PM, Gerhard Hellriegel <gerhard.hellriegel@t-online.de> wrote: > 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-valu...

Re: Notes generated by %SYSFUNC function #2
On Thu, 20 Dec 2007 03:30:16 -0800, RolandRB <rolandberry@HOTMAIL.COM> wrote: >On Dec 20, 11:36 am, jamie.hender...@LLOYDSTSB.CO.UK (Jamie Henderson) >wrote: >> I am running some proc sql code within Enterprise Guide which is throwing >> out some annoying notes, although the sql code completes as expected. I >> was wondering if someone here could help me out and tweak my code slightly >> so as to stop these notes appearing. >> >> The dataset I am reading in is expanded upon monthly, with 8 variables >> added to each month - with the varia...

%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=...

Re: INTNX documentation
On Thu, 5 Mar 2009 11:04:34 -0500, "Gerhard Hellriegel" <gerhard.hellriegel@T-ONLINE.DE> said: > Thank you! That works fine! > Why such things are not in the documentation? They are. "Requirement: The type of interval (date, datetime, or time) must match the type of value in start-from and increment." <http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a000212700.htm> The ability to convert any date interval name to a datetime interval name is mentioned in <http://support.sas.com/onlinedoc/913/getDoc/en/lrcon.hlp/a000990883.htm#a001115672>...

%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 ! ...

Re: INTNX documentation
1593 data _null_; 1594 last_month_dt = intnx("DTmonth",datetime(),-1); 1595 put (l:)(=datetime.); 1596 run; last_month_dt=01FEB09:00:00:00 On 3/5/09, Gerhard Hellriegel <gerhard.hellriegel@t-online.de> wrote: > 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:...

%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
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; ...

SYSFUNC with a WHERE condition
Hi there, I am using %SYSFUNC(open) with a WHERE condition so that it only looks at a subset of observations from the dataset that match the conditoin. But when I do this, I am having problems reading the data without errors. %LET table_id = %SYSFUNC(open (table (WHERE=(&condition1)) )); %PUT %sysfunc(attrn(&table_id_id,nobs)); THIS prints the same number of observations as the dataset, no matter what the condition is... So doing something like this: %DO i = 1 %to %SYSFUNC(ATTRN(&table_id,nobs)); %LETrc=%SYSFUNC(FETCHOBS(&table_id,&i)); .. .. .. ....

Re: INTNX documentation
On Thu, 5 Mar 2009 09:16:42 -0500, Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE> wrote: >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 - &...

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

%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...

%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 ...

Re: %sysfunc with CATS function
You don't need CATS in macro language to concatenate strings. There may be some useful application of CATS in macro language but this it not one of them. 9223 %let string = THE_TIME_IS_&hhmm; 9224 %put string = &string; string = THE_TIME_IS_0905 On 10/8/09, ajs2004@bigfoot.com <ajs2004@bigfoot.com> wrote: > 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, ...

SYSFUNC (QSYSFUNC) and QUOTES
hi ... any takers ??? in the following, the only %LET STNUM= version that works is the one in which no quotes are placed around the two-letter state abbreviation can some "macro guru" please tell me why * example 1 ... works; data _null_; call symputx('stnum',stfips('NC')); run; %put &stnum; * example 2 ... does not work; %let stnum=%sysfunc(stfips('NC')); %put &stnum; * example 3 ... does not work; %let stnum=%qsysfunc(stfips('NC')); %put &stnum; * example 4 ... works; %let stnum=%sysfunc(stfips(NC)); %put &stnum; and, same issu...

%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 with CATS function #3
On Thu, 8 Oct 2009 05:36:11 -0700, ajs2004@bigfoot.com <ajs2004@BIGFOOT.COM> wrote: .... > >1 %let t = '09:05't; >2 >3 %let hhmm = %sysfunc(compress(%sysfunc(putn( &t, >tod5.)),":")); >4 %put hhmm = &hhmm; >hhmm = 0905 >5 >6 %let string = %sysfunc ( cats( THE_TIME_IS_, &hhmm ) ); >7 %put string=&string; >string=THE_TIME_IS_905 >8 >9 data _null_; string = cats ( "THE_TIME_IS_", "&hhmm" ); put >string=; run; > >string=THE_TIME_IS_09...

%SYSFUNC(INTNX(...))
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 we...

Re: %sysfunc with CATS function #2
The reason is that CATS is a SAS function, not a macro function, so it obeys SAS rules. CATS automatically does input/put for you, and in this case it does it unhelpfully. It takes the numeric argument 0905 and says 'hmm, that is really 905' by way of put(0905,BEST12.) which of course strips the zero. Not sure how to get around that, but as DATA _NULL_ says, CATS is unnecessary (Generally, at least) in macro vars. -Joe On Thu, Oct 8, 2009 at 7:36 AM, ajs2004@bigfoot.com <ajs2004@bigfoot.com>wrote: > The program below sets up a variable &hhmm with a value of '0905...

%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) ...

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...

R e: %SYSFUNC and PUT function
Hi TMK. You need to use the PUTN function with %SYSFUNC, rather than the PUT statment. %SYSFUNC executes a SAS function. Guido --- 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 %the...

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 ...

%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 ...