Desktop productivity for business analysts and programmers

ERROR: The function LENGTH referenced by the %SYSFUNC or %QSYSFUNC macro function has too few argume

Accepted Solution Solved
Reply
Contributor
Posts: 42
Accepted Solution

ERROR: The function LENGTH referenced by the %SYSFUNC or %QSYSFUNC macro function has too few argume

[ Edited ]

Hello - Having a nightmare with this. 

 

Just trying to parse 1 variable from VA into a SAS program, and for it to do something if there's a value parsed in, and to do something else if there isn't one. 

 

If I run the below code though in EG, I get "ERROR: The function LENGTH referenced by the %SYSFUNC or %QSYSFUNC macro function has too few arguments", but I can't see what the problem is. 

 

Could anyone help please!? We're not very good at the moment with passing parameters in from Visual Analystics, and this is our first attempt. 

 

data _null_;
rc = stpsrv_header('Content-disposition','attachment; filename=FTELoad.csv');
run;

 

%global va_date;
%let _ODSSTYLE=seaside;
%let _ODSDEST=TAGSETS.CSV;

libname int meta library="Int" metaout=data;

%stpbegin;
%let var_va_date = &va_date;
%macro FTE(var_va_date);

%if (%sysfunc(length(&var_va_date)) >1) %then %do;
%put &var_va_date;
%put &va_date;

proc print data=int.intra label noobs;
where va_date = "&var_va_date." and report_type = 'Z';
run;
%end;
%else %do;
proc print data=int.intraintra label noobs;
where va_date = 'Today' and report_type = 'Z';
%end;
%mend FTE;
%FTE(&var_va_date);
%stpend;


Accepted Solutions
Solution
‎08-14-2017 10:42 AM
Super User
Posts: 5,610

Re: ERROR: The function LENGTH referenced by the %SYSFUNC or %QSYSFUNC macro function has too few ar

The easiest fix is probably this:

 

%if %length(&var_va_date) > 0 %then %do;

 

In fact, in macro language 0 is false and other integers are true.  So you could use:

 

%if %length(&var_va_date) %then %do;

 

Also note, the %LENGTH function will actually return 0 for null strings (unlike the DATA step LENGTH function).

 

View solution in original post


All Replies
Super User
Posts: 8,061

Re: ERROR: The function LENGTH referenced by the %SYSFUNC or %QSYSFUNC macro function has too few ar

If &va_date is existing but empty, then

%sysfunc(length(&var_va_date))

will resolve to

%sysfunc(length())

and cause the error.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Super User
Posts: 8,177

Re: ERROR: The function LENGTH referenced by the %SYSFUNC or %QSYSFUNC macro function has too few ar

This code works:

%let var_va=ABCDEFGHIJKLMN;

%macro tmp;
%if %sysfunc(length(&var_va.)) > 1 %then %put Ok;
%else %put Not;
%put %sysfunc(length(&var_va.));
%mend tmp;

%tmp;

Maybe post some more of the log where it happens (you could try dropping the brackets and adding the dot after the macro (should do this all the tie anyways, but it should matter in this case).

What I suspect is happening is that &var_va. has something inside it that doesn't conform to the function signature, e.g.
ABC,DEF,GHI

Would fail as the procedure does not want three parameters.

As you have't shown what var_va resolves to its hard to say.

Solution
‎08-14-2017 10:42 AM
Super User
Posts: 5,610

Re: ERROR: The function LENGTH referenced by the %SYSFUNC or %QSYSFUNC macro function has too few ar

The easiest fix is probably this:

 

%if %length(&var_va_date) > 0 %then %do;

 

In fact, in macro language 0 is false and other integers are true.  So you could use:

 

%if %length(&var_va_date) %then %do;

 

Also note, the %LENGTH function will actually return 0 for null strings (unlike the DATA step LENGTH function).

 

Contributor
Posts: 42

Re: ERROR: The function LENGTH referenced by the %SYSFUNC or %QSYSFUNC macro function has too few ar

[ Edited ]
Posted in reply to Astounding

Great - thanks everyone. I've got this working now and it's helped prove a point for us.

 

This was to try to get around a problem we're seeing, where we THOUGHT that the paramater wasn't being parsed by Visual Analytics, but turns out that it is always being parsed. 

 

va_date.PNG

 

The code works fine now, but every 3rd or 4th time I double click the va_date in VA (see attached screenshot), instead of getting the data from the stored process (which works great otherwise) I get a CSV with the log file which says No oberservations in data set. 

 

It doesn't seem reliable, even though there are millions of rows in the dataset. If I pass through a different date each time, the problem seems less likely to occur. I can replicate the problem by choosing the same data twice - the first file will download fine and have thousands of rows, the second file will say no obs. I've tried different browsers in case it was a caching issue or something. 

 

Has anyone had experience of this before as well please!? It's new territory here...

NOTE: No observations in data set INT.INTRANET_ENROL_LOAD.

NOTE: PROCEDURE PRINT used (Total process time):

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 245 views
  • 2 likes
  • 4 in conversation