Calcite | Level 5

## Report

Use SASHELP.HEART
Write a macro to do the following.
Find summary statistics N, Mean , Median, Std , Min, Max for Weight by categories in
Weight_status, and Diastolic BP by categories in BP_status
The n will be reported to 0 decimal and mean and median will be reported to 1 decimals. The standard
deviation (SD) will be reported to 2 decimal. The min and max will be reported to 0 decimal.
Display as below using Proc report to an .rtf file

4 REPLIES 4
Tourmaline | Level 20

## Re: Report

Why do you want a macro that does so?

Super User

## Re: Report

Since a standard report will do that what is the Macro actually supposed to accomplish? Typically a macro is used to be somewhat dynamic with something in the code changing in response to values of data or parameters. You do not mention any such need.

If you expect someone to do your homework, expect to get asked a lot of "what have you tried so far" questions.

Calcite | Level 5

## Re: Report

data s;
set sashelp.heart;
run;
proc sort data=s;
by status;
run;

proc freq data=s;
table status/nocum out=x;
run;

proc sql;
select count into :n1 - :n2 from x
order by status;
run;
%put &n1,&n2;

proc means data=s N mean median std min max;
var weight;
class weight_status;
by Status;
output out=outp;
run;

data s2;
set outp(drop=_type_ _freq_);
if missing(status) or missing(weight_status) then delete;
run;

proc means data=s N mean median std min max;
var Diastolic;
class bp_Status;
by status;
output out=outp1;
run;

data s3;
set outp1(drop=_type_ _freq_);
if missing(status) or missing(bp_status) then delete;
run;

proc transpose data=s3 out=s4;
by status BP_Status ;
var Diastolic;
/*id abbre;*/
run;

proc transpose data=s4 out=s5;
by status _name_;
var COL1 col2 col3 col4 col5;
/*id abbre;*/
run;

column Category Summary_statistics ("Dead" ND ) ("Alive" NA );
define Category/ "Category" ;
define ND/ "East*(N=&n2)";
define NA/ "West*(N=&n1)";
run;

Diamond | Level 26

## Re: Report

I point out that there's no macro involved here in your code, there are macro variables, which is a different thing that a macro. And its impossible to see how a macro would apply in this assignment, although it is possible to see how macro variables apply here as you have shown. If your professor is giving you an assignment and he doesn't distinguish between these two, then your professor needs to learn the proper terminology.

By the way, now that you have shown us actual code, what is wrong with the code?

--
Paige Miller
Discussion stats
• 4 replies
• 471 views
• 0 likes
• 4 in conversation