BookmarkSubscribeRSS Feed
Aditi24
Obsidian | Level 7

Hi,

I am using a SAS code which have macros within a macro. When I execute this, the output is not getting transferref to the .lst file(which contains the output of the print proc). All I get is an empty .lst file.

Please refer the code below:-

 

proc printto print="&protpath/outlist/program_d.lst"
              log  ="&protpath/outlog/program_d.log"   new;
run;
%macro program_d(callid=);
 
%put ;
%put -----------------------------------------------------------------------------;
%put --- Start of %upcase(&sysmacroname) macro                                    ;
%put ---   callid=&callid                                                         ;
%put -----------------------------------------------------------------------------;
%put ;
 
%local  report_name;
%let    report_name=&sysmacroname;
 
%*** Bring in global report macro parameters and perform other global functions. ****;
%infrastructure2(report=&report_name,callid=&callid);
%if &_err_flag=Y %then
%goto exit;
 


data class1; 
  set sashelp.class; 
run;

%macro meann(datain=);
	proc means data=&datain median min max ;
	  by sex;
	  var Age Height Weight ;
	run;

	proc print data=&datain;
	title "Is datain in the list file";
	run;
	
%mend meann;

%meann(datain=class1);
 
%rtfsymbl(groups=_ALL_);
%exit:
%if "&debug"="N" %then %wrapup;
%put;
%put ---End of %upcase(&sysmacroname) macro;
%put;
%mend program_d;
%program_d(callid=001);
proc printto;
run;
4 REPLIES 4
Ksharp
Super User
options source source2 mprint mlogic symbolgen;
Aditi24
Obsidian | Level 7

@Ksharp: Could you please explain that?

RW9
Diamond | Level 26 RW9
Diamond | Level 26

What @Ksharp meant is turn on the debug options.  These print the values of macro variables, what the macro code evaluates to.  From what you have posted there is no way we can provide any answers.  There are various other macro calls within that code, and other macro variables.  We do not know what these do, represent, or contain.  This comes under the heading of obfuscation.  Why do you need to have a macro, which all it does it proc means, and lists the output?  Use base SAS code, everyone will understand it then.

Aditi24
Obsidian | Level 7
@RW9: Yeah I'll do that. Thanks for making the point clear.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1107 views
  • 0 likes
  • 3 in conversation