BookmarkSubscribeRSS Feed
ybz12003
Rhodochrosite | Level 12

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)    
9 REPLIES 9
ybz12003
Rhodochrosite | Level 12
The dis_order comment seems complicated. Does the data need to be sorted out first, then I have to figure out which needs to be listed in the order? Any other simpler procedure could be used?
PaigeMiller
Diamond | Level 26

I still think the easiest thing to do is to use the %TABLEN macro. Other approaches would seem to require even more work.

--
Paige Miller
ybz12003
Rhodochrosite | Level 12
I have the other extra ten variables that need to be counted. I would like to avoid figuring out the order of each category.
Reeza
Super User
You don't need to figure out the order of each category that I can see unless you want it different than the default output. Do you want it different than the default? If so, how?
ballardw
Super User

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
Rhodochrosite | Level 12
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.
ballardw
Super User

@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.

 

ybz12003
Rhodochrosite | Level 12
Race 4 = other, Race 5 = unknown
Premature = 1 or 0

SAS Innovate 2025: Register Now

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!

What is ANOVA?

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.

Discussion stats
  • 9 replies
  • 1003 views
  • 1 like
  • 4 in conversation