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,
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.