Hello,
I could like to create a table for listing the Counts and Percentages (One digit behind decimal) of three categories (Gender/Race/Premature) in two classes of Patients (ER and Hospital). Gender contains two subgroups, M and F. Race contains five subgroups, and I only need 1-3 subgroups. Premature contains Y/N subgroups. All the variables are numeric. The final result I would like to get is similar to the table shown below. Please advise how to approach it; Proc Freq, Proc tabulate, or something else. Thanks.
Hospital Patient | ER Patient | |
Gender Male Female |
||
Race White Black Hispanic |
||
Premature (Y) |
I believe that the %TABLEN macro will do what you want.
I still think the easiest thing to do is to use the %TABLEN macro. Other approaches would seem to require even more work.
You need to define exactly what "Race contains five subgroups, and I only need 1-3 subgroups." means. Does this mean to exclude any observations that have race not in the desired subgroups entirely from the table? Combine some of the groups (which you did not define) into those shown, or just ignore 2 classes and not include them in the report but count the observations in the Gender and Premature? This requirement may impose a bit of data restructuring depending on your answer
By "Premature contains Y/N subgroups. All the variables are numeric" does this mean that Premature has a numeric value of 1 for Yes and 0 for No? If not what is the actual coding?
If it is coded 1/0 then the SUM statistic gives you the number of Yes and Mean will give you a decimal percentage of yes
@ybz12003 wrote:
Yes.
Race has 1-5 subgroups, and I only need 1-3 groups. Group 4 and 5 will be discharged.
Premature = 1 is the one I need.
Does not quite answer the questions. Are the observations for race where it is 4 or 5 removed from the data entirely?
And what other value does Premature take? If it is not 0 we need to know.
Best, as has been requested for many projects is to include an actual example of the data set as data step code so we do not have to guess.
Then show the desired result given the example data set.
@ybz12003 wrote:
Yes.
Race has 1-5 subgroups, and I only need 1-3 groups. Group 4 and 5 will be discharged.
Premature = 1 is the one I need.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.