I would like to create a dataset that i want to use as a treatment group as denominator for calculated field after
For example:
patientid | group |
1234 | placebo |
4564 | placebo |
5646 | treatment |
6544 | placebo |
2345 | treatment |
2343 | placebo |
I want to do something like:
group | count |
placebo | 4 |
treatment | 2 |
I want count for placebo and treatment as a stored variable so that it is updated automatically when I use Placebo total denominator as 4 and treatment denominator as 2 for all proc freq calculations
I tried
proc sql;
create table group_denominator as
select group, count(*) as count
from test;
quit;
but it doesn't do what i would like it to
Thanks
proc sql;
create table group_denominator as
select group, count(*) as count
from test
group by group;
quit;
proc freq data=have;
table group;
run;
Hi @radhikaa4
You can try either:
proc sql;
create table group_denominator as
select group, count(*) as count
from test
group by group;
quit;
or
proc freq data=test noprint;
table group / out=group_denominator (drop=percent);
run;
In PROC SQL, the GROUP BY clause enables to compute summary statistics (in your case: n) for each modality of the specified variable (in your case: group).
Best,
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.