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,
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.