BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
RobertWF1
Quartz | Level 8

For example, running proc freq on the following data:

 

 

data test;
input class :$9. gender :$1.;
cards;
Treatment M
Treatment M
Treatment F
Treatment F
Control M
Control M
Control F
Control F
Control F
Control F
;
run;
proc freq data=test;
table gender*class / nopercent norow out=freq_gender;
run;

I'd like to produce the following table with nested header:

 

  Control Treatment
Gender Frequency Col Pct Frequency Col Pct
Female 4 66.67 2 50.00
Male 2 33.33 2 50.00

 

Is that possible in proc freq or do I need to use other procedures?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

I'd probably recommend PROC TABULATE. More control over what is displayed in that procedure. 

View solution in original post

2 REPLIES 2
Reeza
Super User

I'd probably recommend PROC TABULATE. More control over what is displayed in that procedure. 

RobertWF1
Quartz | Level 8
Yes the following worked, thanks Reeza:

proc tabulate data=test;
class gender class;
table gender,class*(n='N'*F=6.0 colpctn='%'*F=6.2);
run;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 2 replies
  • 329 views
  • 3 likes
  • 2 in conversation