BookmarkSubscribeRSS Feed
Beaker
Calcite | Level 5

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?

5 REPLIES 5
data_null__
Jade | Level 19

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
Beaker
Calcite | Level 5

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

data_null__
Jade | Level 19

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
Beaker
Calcite | Level 5

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?


data_null__
Jade | Level 19

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 947 views
  • 3 likes
  • 2 in conversation