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

Hello, 

 

I tried to output the following simple frequency table based on proc freq to excel using proc report. However proc report procedures adding up the count even I change the count as count_ , percent as pct.

 

Any way to prevent that?  

 

nvis   count  percent 

.           20       20

5         10        10

8          70        70

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

HINT: Always show the code of what you attempted.

It may be that you are very close or need much work to do something but without details it is pretty hard to tell. Copy the code from the editor, on the forum open a text box using the </> icon that appears above the message window and paste the text. The text box serves a couple purposes. One, the message windows will reformat text and may result in code that will not run if copy/paste from the forum. Second, it sets text apart from questions or comments.(See below).

 

I am going to guess that you did not provide a roll in a DEFINE statement for the variables Count and Percent. If you do not then the default behavior for numeric values is to treat them as variables to Sum.

To display just the values you already have you would use something like

define count / display;
define percent /display.

View solution in original post

4 REPLIES 4
ballardw
Super User

HINT: Always show the code of what you attempted.

It may be that you are very close or need much work to do something but without details it is pretty hard to tell. Copy the code from the editor, on the forum open a text box using the </> icon that appears above the message window and paste the text. The text box serves a couple purposes. One, the message windows will reformat text and may result in code that will not run if copy/paste from the forum. Second, it sets text apart from questions or comments.(See below).

 

I am going to guess that you did not provide a roll in a DEFINE statement for the variables Count and Percent. If you do not then the default behavior for numeric values is to treat them as variables to Sum.

To display just the values you already have you would use something like

define count / display;
define percent /display.
Ivy
Quartz | Level 8 Ivy
Quartz | Level 8
Thank you, this works! I will post any future question according to your suggestion in the future.
tarheel13
Rhodochrosite | Level 12

you could also use the put function to convert the numbers from proc freq to character variables. that's usually how I do it when I create my tables. 

Ivy
Quartz | Level 8 Ivy
Quartz | Level 8
Thank you, this works!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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