DATA Step, Macro, Functions and more

Help With Call Execute

Accepted Solution Solved
Reply
Contributor
Posts: 30
Accepted Solution

Help With Call Execute

I have the following code::

*****************************************;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

options obs=max;
options symbolgen mprint mlogic ;
%global variable dataset ;
%macro cont(dataset);
%global ds;
%let ds=&dataset.;
proc contents data=&dataset. noprint out=cont_perf;
run;
%mend cont;
%cont(sashelp.cars);
%macro condition;
%if &cnt_nos. <= 10 %then %do;
%put "cnt less than == 10" ;
%end;
%else %do;
%put "cnt more than == 10" ;
%end;
%mend condition;

%macro _var_desc(variable);
%global cnt_nos;
proc sql ;
select
cnt into :cnt_nos
from (
select
count(distinct &variable.) as cnt
from
&ds.
)
;quit;run;
%condition;
%mend _var_desc;

*****************************************;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

 

Now if i execute it this way it works fine:

%_var_desc(Cylinders);
%_var_desc(DriveTrain);
%_var_desc(EngineSize);
%_var_desc(Horsepower);
%_var_desc(Invoice);
%_var_desc(Length);

But if i execute using Call Execute--- It does not got executed correctly.

The macro value does not get refreshed.

I dont know why.

 

data _null_;
set cont_perf;
call execute('%_var_desc('||name||');');
run;

 

Please suggest what should I change.

 

Thanks


Accepted Solutions
Solution
‎06-01-2017 09:06 AM
SAS Employee
Posts: 119

Re: Help With Call Execute

See if nrstr helps.

 

call execute('%nrstr(%_var_desc('||name||')Smiley Wink');

View solution in original post


All Replies
Solution
‎06-01-2017 09:06 AM
SAS Employee
Posts: 119

Re: Help With Call Execute

See if nrstr helps.

 

call execute('%nrstr(%_var_desc('||name||')Smiley Wink');

☑ This topic is solved.

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

Discussion stats
  • 1 reply
  • 139 views
  • 2 likes
  • 2 in conversation