DATA Step, Macro, Functions and more

Need some help with printing macro

Reply
Regular Contributor
Posts: 237

Need some help with printing macro

%Macro EDC(Type,id);
data out_table;
set RF300L3.edc_thick;
where col_ins_id = &id;
run;
%mend;

%macro Html;
ods listing close;
ods html file="/imec/other/imecweb/osp/sp/files/HTML.html" data _null_;
set all_append_and_edc_and_vars;
if type = 'THICK' then call execute('%EDC(THICK,col_ins_id)');
proc print data=out_table;run;

run;

ods html close;
%mend;
%Html;

the problem is the id i have to pass

Message was edited by: Filipvdr Message was edited by: Filipvdr
Super Contributor
Posts: 345

Re: Need some help with printing macro

If "col_ins_id" is a dataset variable, then using cat can help.

[pre]call execute(cats('%EDC(THICK,' col_ins_id, ')');[/pre]
SAS Employee
Posts: 58

Re: Need some help with printing macro

I'm not sure I get what your problem / question is....
Super User
Posts: 11,343

Re: Need some help with printing macro

> %Macro EDC(Type,id);
> data out_table;
> set RF300L3.edc_thick;
> where col_ins_id = &id;
> run;
> %mend;
>
> %macro Html;
> ods listing close;
> ods html
> file="/imec/other/imecweb/osp/sp/files/HTML.html"

Missing semicolon to end ODS HTML statement;


> data _null_;
> set all_append_and_edc_and_vars;
> if type = 'THICK' then call

This may not work as EDC calls a data step and can not nest datasteps.

> execute('%EDC(THICK,col_ins_id)');
> proc print data=out_table;run;
>
> run;
>
> ods html close;
> %mend;
> %Html;
>
> the problem is the id i have to pass
>
> Message was edited by: Filipvdr
>
> Message was edited by: Filipvdr
Regular Contributor
Posts: 237

Re: Need some help with printing macro

so there is no solution to do this kind of working with macro and datasets to print?
Super Contributor
Super Contributor
Posts: 3,174

Re: Need some help with printing macro

First, the ODS statement is missing a trailing semi-colon as was mentioned.
Second, the DATA step that invokes the CALL EXECUTE must have a RUN; statement to terminate / compile the code before invoking the PROC PRINT that follows.

Recommend the OP add the SAS statement below so that the max amount of diagnostic info is generated to the SAS log, and then if there are still problems, REPLY to this post with a COPY/PASTE of the entire SAS-generated log output:

OPTIONS SOURCE SOURCE2 MACROGEN SYMBOLGEN MPRINT /* MLOGIC */;

Also, if there are problems completing a forum post, review this companion forum post (and bookmark it for future reference) with posting guidelines:

http://support.sas.com/forums/thread.jspa?messageID=27609


Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

call execute run statement site:sas.com
Super User
Posts: 10,041

Re: Need some help with printing macro

You should add 'proc print ' into your first macro EDCT. Such as


%Macro EDC(Type,id);
data out_table;
set RF300L3.edc_thick;
where col_ins_id = &id;
run;
proc print data=out_table;run;
%mend;

%macro Html;
ods listing close;
ods html file="/imec/other/imecweb/osp/sp/files/HTML.html" data _null_;
set all_append_and_edc_and_vars;
if type = 'THICK' then call execute('%EDC(THICK,col_ins_id)');


run;

ods html close;
%mend;
%Html;



Because the code generated by call execute is executed after your data _null_;

Ksharp
Ask a Question
Discussion stats
  • 6 replies
  • 249 views
  • 0 likes
  • 6 in conversation