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

Here I have an example of using CALL EXECUTE. I wonder why the second code does not work when I omit the concatenation oeprator.  

data test;
input a $;
cards;
1
2
3
;

data _null_;
	set test end=last;
    call execute('proc print data=sashelp.class (obs='||a||'); run;');
run;

data test;
input a $;
cards;
1
2
3
;

data _null_;
	set test end=last;
    call execute('proc print data=sashelp.class (obs='a'); run;');
run;

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

The call execute function requires a string to be passed to it as its only parameter. This

'proc print data=sashelp.class (obs='a'); run;'

is not a string, it is two strings:

'proc print data=sashelp.class (obs='

'); run;'

and something undefined.  

Function form:

call execute(<string>);

By using the concatenate symbols you are creating one string out of the two given strings and the value held in the variable a.

 

One other thing, as a string in the dataset is given a length of 8 (as you didn't define it!) you may want to use cats:

data _null_;
  set test end=last;
  call execute(cats('proc print data=sashelp.class (obs=',a,'); run;'));
run;

This should remove any blanks around a.

 

 

 

View solution in original post

4 REPLIES 4
Kurt_Bremser
Super User

This message:

ERROR 253-185: The EXECUTE subroutine call has too many arguments.

provides the answer.

CALL EXECUTE expects ONE argument of type character. You are supplying three: a string constant, a variable of type character, and another string constant.

Reeza
Super User

Because it isn't valid SAS code. The string isn't being created, there's no default concatenation. 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

The call execute function requires a string to be passed to it as its only parameter. This

'proc print data=sashelp.class (obs='a'); run;'

is not a string, it is two strings:

'proc print data=sashelp.class (obs='

'); run;'

and something undefined.  

Function form:

call execute(<string>);

By using the concatenate symbols you are creating one string out of the two given strings and the value held in the variable a.

 

One other thing, as a string in the dataset is given a length of 8 (as you didn't define it!) you may want to use cats:

data _null_;
  set test end=last;
  call execute(cats('proc print data=sashelp.class (obs=',a,'); run;'));
run;

This should remove any blanks around a.

 

 

 

SAS_inquisitive
Lapis Lazuli | Level 10

Thank you, all. I was assuming I was creating a string by enclosing variable a in quotation marks.

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