BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ArpitSharma
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenKuhfeld
Ammonite | Level 13

See if nrstr helps.

 

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

View solution in original post

1 REPLY 1
WarrenKuhfeld
Ammonite | Level 13

See if nrstr helps.

 

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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 810 views
  • 3 likes
  • 2 in conversation