I have two datasets
dataset #1: by group
group_assigned | denominator |
placebo | 10 |
treatment | 12 |
dataset #2:
Demographics | treatment | placebo |
Age | ||
Gender | ||
Race | ||
Medications |
the treatment groups changes every data export so i want to set n=# for each group. For this export, something like this:
Demographics | treatment (n=12) | placebo (n=10) |
Age | ||
Gender | ||
Race | ||
Medications |
I tried %macro but i think it is not working
Please clearify the target format of the export and show the code you are using. I don't macro-code is required to solve the problem, i would use labels. The following step adds labels to the variables in dataset work.two.
data _null_;
set groups end=last;
if _n_ = 1 then do;
call execute('proc datasets library=work nolist;');
call execute('modify two;');
call execute('label');
end;
call execute(cats(group_assigned, '=', quote(catx(' ', group_assigned, '(n=', denominator, ')'))));
if last then do;
call execute(';');
call execute('quit;');
end;
run;
See Example 8 here
https://support.sas.com/resources/papers/proceedings/pdfs/sgf2008/173-2008.pdf
The link in the document to the code shows exactly how to do it.
http://support.sas.com/rnd/papers/sgf2008/complex_reports.zip
@monday89 wrote:
I have two datasets
dataset #1: by group
group_assigned denominator placebo 10 treatment 12
dataset #2:
Demographics treatment placebo Age Gender Race Medications
the treatment groups changes every data export so i want to set n=# for each group. For this export, something like this:
Demographics treatment (n=12) placebo (n=10) Age Gender Race Medications
I tried %macro but i think it is not working
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!
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.