BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Priyamvada07
Obsidian | Level 7

I have the following data

DATA HAVE;
input year dz $8. area;
cards;
2000 stroke 08
2000 stroke 06
2000 stroke 06
;
run;

 

After using proc freq

proc freq data=have;
table area*dz/ list nocum ;
run;

 

I get the below output

Priyamvada07_0-1617136480788.png

 

In this output

1. I want to delete the 'dz', what can I do to delete this column?

2. I want a row in the end that gives 'total', what can I do to get a 'total' row?

 

Thank you! 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

What would go on that "total" row?

 

Your Have data step is likely incorrect and you want either (if dz is supposed to be only "stroke" and area is numeric

DATA HAVE;
input year dz :$8. area;
cards;
2000 stroke 08
2000 stroke 06
2000 stroke 06
;
run;

OR if area is supposed to be character.

DATA HAVE;
input year dz :$8. area $;
cards;
2000 stroke 08
2000 stroke 06
2000 stroke 06
;
run;

I suspect you are not providing enough information as with this small sample you get the same counts and percentages with:

proc freq data=have;
   tables area;
run;
 

Perhaps you are looking for a different reporting procedure. Here is a "total" row done with Proc Tabulate:

proc tabulate data=have;
   class area;
   tables area=' ' all='Total',
          n='Frequency' pctn='Percent'
          /box=area
   ;
run;
 

Tabulate has a different set of options as it does different statistics and has the ability to nest variables in both row, column and Page(separate table) dimensions. The Area=' ' suppresses the default label of the Area variable, box places it into what would normally be an empty box in the upper left. "All" requests a total within a dimension, the ='Total' provides a label. N requests a count and Pctn asks for the basic percentage and again the ='text' provides a label other than the default N or PCTN.

View solution in original post

1 REPLY 1
ballardw
Super User

What would go on that "total" row?

 

Your Have data step is likely incorrect and you want either (if dz is supposed to be only "stroke" and area is numeric

DATA HAVE;
input year dz :$8. area;
cards;
2000 stroke 08
2000 stroke 06
2000 stroke 06
;
run;

OR if area is supposed to be character.

DATA HAVE;
input year dz :$8. area $;
cards;
2000 stroke 08
2000 stroke 06
2000 stroke 06
;
run;

I suspect you are not providing enough information as with this small sample you get the same counts and percentages with:

proc freq data=have;
   tables area;
run;
 

Perhaps you are looking for a different reporting procedure. Here is a "total" row done with Proc Tabulate:

proc tabulate data=have;
   class area;
   tables area=' ' all='Total',
          n='Frequency' pctn='Percent'
          /box=area
   ;
run;
 

Tabulate has a different set of options as it does different statistics and has the ability to nest variables in both row, column and Page(separate table) dimensions. The Area=' ' suppresses the default label of the Area variable, box places it into what would normally be an empty box in the upper left. "All" requests a total within a dimension, the ='Total' provides a label. N requests a count and Pctn asks for the basic percentage and again the ='text' provides a label other than the default N or PCTN.

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
  • 1 reply
  • 517 views
  • 3 likes
  • 2 in conversation