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-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
  • 4 replies
  • 397 views
  • 0 likes
  • 3 in conversation