DATA Step, Macro, Functions and more

Need help with %syscall compcost

Reply
New Contributor
Posts: 3

Need help with %syscall compcost

Hi,

Does anyone have an example of the correct way to enter the syntax for '%syscall compcost'? Having a real hard time trying to find an example of this on the web!

I've gone down the path of trial and error, and I've found that the following syntax at least doesn't trigger an error:

%let a = insert;

%let b = 1;

%syscall compcost(a,b);

However, the changes don't seem to be taking effect when I perform a COMPGED function.

I know how to use compcost within a data step, but for the work I'm doing at the moment it will be more practical to modify the COMPGED values on the global scale using %syscall compcost. Can anyone help?

Respected Advisor
Posts: 3,777

Re: Need help with %syscall compcost

This implies "to me" that it does work.

%macro c;
  
%local a b s;
   %let s = xballoon;
   %let a = insert;
   %do b = 0 %to 50 %by 10;
     
%syscall compcost(a,b);
      %let ged=%sysfunc(compged(&s,balloon));
      %put &=ged &=b;
      %end;
  
%mend;
%
c;

GED=
0 B=0
GED=
10 B=10
GED=
20 B=20
GED=
30 B=30
GED=
40 B=40
GED=
50 B=50
New Contributor
Posts: 3

Re: Need help with %syscall compcost

Oh ok... so thats working within a macro statement. Maybe my problem is that I'm trying to use this function in open code. I'll package what I'm doing into a macro instead and see how that goes. Cheers for the advice!Smiley Happy

Respected Advisor
Posts: 3,777

Re: Need help with %syscall compcost

I used the macro to loop the value B but this open code appears to work.  What version of SAS are you using?

%let s = xballoon;
%let a = insert;
%let b = 5000;
%syscall compcost(a,b);
%let ged=%sysfunc(compged(&s,balloon));
%put &=ged &=b;

35        
%let s = xballoon;
36         %let a = insert;
37         %let b = 5000;
38         %syscall compcost(a,b);
39         %let ged=%sysfunc(compged(&s,balloon));
40         %put &=ged &=b;
GED=5000 B=5000
New Contributor
Posts: 3

Re: Need help with %syscall compcost

Version 9.3, I think...

What happens with the following bit of code? I'd give it a go myself but I can't access from home lol

%let a = insert;

%let b = 5000;

%syscall compcost(a,b);

data ged_test;

str1 = 'balloon';

str2 = 'xballoon';

ged = compged(str1, str2);

run;

Is the value of variable 'ged' in the resulting dataset still 5000?


Respected Advisor
Posts: 3,777

Re: Need help with %syscall compcost

No it appears the SYSCALLed COMPCOST only works for %SYSFUNCed COMPGED.  See slightly modified example.  If you un-comment the CALL COMPCOST in the data step you can execute COMCOST with values of &A and &B;

%let a = insert;
%let b = 5000;
%syscall compcost(a,b);

data _null_;
  
*if _n_ eq 1 then call compcost("&a=",&b);
   str1 =
'balloon ';
   str2 =
'xballoon';
   ged = compged(str2, str1);
*modified you had str1 first.;
  
put ged=;
   ged2 = compged(str1, str2); *yours;
  
put ged2=;

  
run;
%put NOTE: %sysfunc(compged(xballoon,balloon));
%put NOTE: %sysfunc(compged(balloon,xballoon));


10-24-2014 10-03-01 AM.png
Ask a Question
Discussion stats
  • 5 replies
  • 218 views
  • 3 likes
  • 2 in conversation