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
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: