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-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
  • 4 replies
  • 787 views
  • 0 likes
  • 3 in conversation