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,

 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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