BookmarkSubscribeRSS Feed
radhikaa4
Calcite | Level 5

I would like to create a dataset that i want to use as a treatment group as denominator for calculated field after 

 

For example:

 

patientidgroup
1234placebo
4564placebo
5646treatment
6544placebo
2345treatment
2343placebo

 

I want to do something like:

groupcount
placebo4
treatment2

 

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

3 REPLIES 3
novinosrin
Tourmaline | Level 20
proc sql;

create table group_denominator as

select group, count(*) as count

from test
group by group;

quit;
PaigeMiller
Diamond | Level 26
proc freq data=have;
    table group;
run;
--
Paige Miller
ed_sas_member
Meteorite | Level 14

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,

 

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1306 views
  • 0 likes
  • 4 in conversation